Authored by 姜枫

请求拦截新商品详情页url

... ... @@ -11,7 +11,7 @@ let ONE_DAY = 60 * 60 * 24;
const MAX_QPS = config.maxQps;
const PAGES = {
'/product/\\/pro_([\\d]+)_([\\d]+)\\/(.*)/': 5,
'/product/\\/p([\\d]+)(.*)/': 5,
'/product/list/index': 5
};
... ... @@ -39,6 +39,8 @@ module.exports = (req, res, next) => {
remoteIp = arr[0];
}
remoteIp = _.trim(remoteIp);
if (remoteIp &&
!_.get(req.app.locals, 'pc.sys.noLimiter') &&
!_.includes(IP_WHITE_LIST, remoteIp)) { // 判断获取remoteIp成功,并且开关未关闭
... ... @@ -56,6 +58,10 @@ module.exports = (req, res, next) => {
let pageKey = urlJoin(appPath, route.toString()); // route may be a regexp
let pageIncr = PAGES[pageKey] || 0;
if (/^\/p([\d]+)/.test(req.path)) {
pageIncr = 5;
}
if (pageIncr > 0) {
cache.incrAsync(key, pageIncr);
}
... ...