revert log; fix repeating setting cache in readhub
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user