fix(chore): contentExpire not work

This commit is contained in:
DIYgod
2019-05-13 00:24:48 +08:00
parent aadc66ba31
commit c4cd0ab495
6 changed files with 9 additions and 23 deletions
+4 -4
View File
@@ -38,13 +38,13 @@ module.exports = function(app, options = {}) {
if (key) {
let value = await redisClient.get(key);
if (value) {
await redisClient.expire(key, config.cache.routeExpire);
await redisClient.expire(key, config.cache.contentExpire);
value = value + '';
}
return value;
}
},
set: async function(key, value, maxAge = config.cache.routeExpire) {
set: async function(key, value, maxAge = config.cache.contentExpire) {
if (await redisClient.exists(key)) {
logger.warn(`repeated key: ${key}, ${value}`);
return;
@@ -89,7 +89,7 @@ module.exports = function(app, options = {}) {
return value;
}
},
set: (key, value, maxAge = config.cache.routeExpire) => {
set: (key, value, maxAge = config.cache.contentExpire) => {
if (!value || value === 'undefined') {
value = '';
}
@@ -125,7 +125,7 @@ module.exports = function(app, options = {}) {
};
}
app.context.cache.tryGet = async function(key, getValueFunc, maxAge = config.cache.routeExpire) {
app.context.cache.tryGet = async function(key, getValueFunc, maxAge = config.cache.contentExpire) {
let v = await this.get(key);
if (!v) {
v = await getValueFunc();