Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
姜枫
8 years ago
Commit
c6ececadfc96205bee89ef2b1a133f0bf41817d9
1 parent
aee8e41c
fix
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
5 deletions
doraemon/middleware/limiter/rules/qps-limit.js
doraemon/middleware/limiter/rules/qps-limit.js
View file @
c6ececa
...
...
@@ -29,8 +29,6 @@ module.exports = (limiter, policy) => {
const
key
=
`
pc
:
limiter
:
$
{
limiter
.
remoteIp
}
`
;
let
isNew
=
true
;
res
.
on
(
'render'
,
function
()
{
let
route
=
req
.
route
?
req
.
route
.
path
:
''
;
let
appPath
=
req
.
app
.
mountpath
;
...
...
@@ -46,15 +44,14 @@ module.exports = (limiter, policy) => {
pageIncr
=
5
;
}
if
(
pageIncr
>
0
&&
!
isNew
)
{
cache
.
incrAsync
(
key
,
pageIncr
);
if
(
pageIncr
>
0
)
{
cache
.
incr
(
key
,
pageIncr
,
(
err
)
=>
{});
}
});
return
cache
.
getAsync
(
key
).
then
((
result
)
=>
{
logger
.
debug
(
'qps limiter: '
+
key
+
'@'
+
result
+
' max: '
+
MAX_QPS
);
if
(
result
&&
_
.
isNumber
(
result
))
{
isNew
=
false
;
if
(
result
===
-
1
)
{
return
Promise
.
resolve
(
true
);
}
...
...
Please
register
or
login
to post a comment