Authored by 周少峰

Merge branch 'hotfix/memcached-incr' into hotfix/pz

@@ -29,6 +29,8 @@ module.exports = (limiter, policy) => { @@ -29,6 +29,8 @@ module.exports = (limiter, policy) => {
29 29
30 const key = `pc:limiter:${limiter.remoteIp}`; 30 const key = `pc:limiter:${limiter.remoteIp}`;
31 31
  32 + let isNew = false;
  33 +
32 res.on('render', function() { 34 res.on('render', function() {
33 let route = req.route ? req.route.path : ''; 35 let route = req.route ? req.route.path : '';
34 let appPath = req.app.mountpath; 36 let appPath = req.app.mountpath;
@@ -44,7 +46,7 @@ module.exports = (limiter, policy) => { @@ -44,7 +46,7 @@ module.exports = (limiter, policy) => {
44 pageIncr = 5; 46 pageIncr = 5;
45 } 47 }
46 48
47 - if (pageIncr > 0) { 49 + if (pageIncr > 0 && !isNew) {
48 cache.incrAsync(key, pageIncr); 50 cache.incrAsync(key, pageIncr);
49 } 51 }
50 }); 52 });
@@ -70,6 +72,7 @@ module.exports = (limiter, policy) => { @@ -70,6 +72,7 @@ module.exports = (limiter, policy) => {
70 } 72 }
71 } else { 73 } else {
72 cache.setAsync(key, 1, 60); // 设置key,1m失效 74 cache.setAsync(key, 1, 60); // 设置key,1m失效
  75 + isNew = true;
73 return Promise.resolve(true); 76 return Promise.resolve(true);
74 } 77 }
75 }); 78 });