...
|
...
|
@@ -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);
|
|
|
}
|
...
|
...
|
|