...
|
...
|
@@ -53,10 +53,13 @@ class Http { |
|
|
// 写缓存, 否则返回 Slave 缓存服务器的数据
|
|
|
if (config.useCache && cacheOption) {
|
|
|
const cacheTime = _.isNumber(cacheOption) ? cacheOption : 60;
|
|
|
const catchErr = (err) => {
|
|
|
log.error(`cache: ${err.toString()}`);
|
|
|
};
|
|
|
|
|
|
reqId = reqId || this._getReqId(options);
|
|
|
cache.set(`apiCache:${reqId}`, result, cacheTime);
|
|
|
cache.setSlave(`apiCache:${reqId}`, result, 86400); // 二级缓存存储一天
|
|
|
cache.set(`apiCache:${reqId}`, result, cacheTime).catch(catchErr);
|
|
|
cache.setSlave(`apiCache:${reqId}`, result, 86400).catch(catchErr); // 二级缓存存储一天
|
|
|
}
|
|
|
|
|
|
log.info(`get api success: use: ${duration}ms`);
|
...
|
...
|
|