revert log; fix repeating setting cache in readhub

This commit is contained in:
DIYgod
2019-03-27 19:04:09 +08:00
parent 5676607046
commit 9e2b99f5ac
2 changed files with 3 additions and 8 deletions
+1 -6
View File
@@ -43,10 +43,7 @@ module.exports = function(app, options = {}) {
return value;
}
},
set: async function(key, value, maxAge = 24 * 60 * 60) {
if (await this.get(key)) {
logger.warn(`repeated key: ${key}, ${value}`);
}
set: async (key, value, maxAge = 24 * 60 * 60) => {
if (!value || value === 'undefined') {
value = '';
}
@@ -144,7 +141,6 @@ module.exports = function(app, options = {}) {
let type;
let ok = false;
logger.warn(`getCache in ${key}`);
if (value) {
ctx.response.status = 200;
type = (await globalCache.get(tkey)) || 'text/html';
@@ -244,7 +240,6 @@ module.exports = function(app, options = {}) {
try {
ok = await getCache(ctx, key, tkey);
} catch (e) {
logger.warn(`getCache catch ${e instanceof Error ? e.stack : e}`);
ok = false;
}
if (ok) {
+2 -2
View File
@@ -78,6 +78,8 @@ module.exports = async (ctx) => {
guid: id,
link,
};
await ctx.cache.set(link, JSON.stringify(item), 24 * 60 * 60);
} else {
const description = news.summaryAuto || news.summary || news.title;
item = {
@@ -88,8 +90,6 @@ module.exports = async (ctx) => {
link: news.url || news.mobileUrl,
};
}
await ctx.cache.set(link, JSON.stringify(item), 24 * 60 * 60);
return Promise.resolve(item);
})
);