Showing
1 changed file
with
7 additions
and
6 deletions
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | const _ = require('lodash'); | 3 | const _ = require('lodash'); |
4 | const logger = global.yoho.logger; | 4 | const logger = global.yoho.logger; |
5 | const Geetest = require('geetest'); | 5 | const Geetest = require('geetest'); |
6 | +const config = global.yoho.config; | ||
6 | const co = Promise.coroutine; | 7 | const co = Promise.coroutine; |
7 | const cache = global.yoho.cache.master; | 8 | const cache = global.yoho.cache.master; |
8 | const captcha = new Geetest({ | 9 | const captcha = new Geetest({ |
@@ -65,13 +66,13 @@ exports.submit = (req, res) => { | @@ -65,13 +66,13 @@ exports.submit = (req, res) => { | ||
65 | remoteIp = arr[0]; | 66 | remoteIp = arr[0]; |
66 | } | 67 | } |
67 | 68 | ||
68 | - let key = `pc:limiter:${remoteIp}`; | ||
69 | - let key10m = `pc:limiter:10m:${remoteIp}`; | 69 | + let operations = [cache.delAsync(`${config.app}:limiter:${remoteIp}`)]; |
70 | 70 | ||
71 | - yield Promise.all([ | ||
72 | - cache.delAsync(key), | ||
73 | - cache.delAsync(key10m) | ||
74 | - ]); | 71 | + _.forEach(config.REQUEST_LIMIT, (val, key) => { |
72 | + operations.push(cache.delAsync(`${config.app}:limiter:${key}:max:${remoteIp}`)); | ||
73 | + }); | ||
74 | + | ||
75 | + yield Promise.all(operations); | ||
75 | 76 | ||
76 | return res.json({ | 77 | return res.json({ |
77 | code: 200 | 78 | code: 200 |
-
Please register or login to post a comment