fix cache type

This commit is contained in:
DIYgod
2019-04-21 20:19:54 +08:00
parent 9a838db0f6
commit ec9f9aa018
2 changed files with 6 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ module.exports = function(app, options = {}) {
if (value) {
await redisClient.expire(key, 24 * 60 * 60);
}
return value;
return value + '';
}
},
set: async function(key, value, maxAge = 24 * 60 * 60) {
@@ -81,7 +81,7 @@ module.exports = function(app, options = {}) {
app.context.cache = {
get: (key) => {
if (key) {
return routeCache.get(key);
return routeCache.get(key) + '';
}
},
set: (key, value, maxAge = 24 * 60 * 60) => {

View File

@@ -5,12 +5,12 @@ module.exports = async (ctx, next) => {
// decode HTML entities
if (ctx.state.data) {
ctx.state.data.title && (ctx.state.data.title = he.decode(ctx.state.data.title));
ctx.state.data.description && (ctx.state.data.description = he.decode(ctx.state.data.description));
ctx.state.data.title && (ctx.state.data.title = he.decode(ctx.state.data.title + ''));
ctx.state.data.description && (ctx.state.data.description = he.decode(ctx.state.data.description + ''));
ctx.state.data.item &&
ctx.state.data.item.forEach((item) => {
item.title && (item.title = he.decode(item.title));
item.description && (item.description = he.decode(item.description));
item.title && (item.title = he.decode(item.title + ''));
item.description && (item.description = he.decode(item.description + ''));
});
}