diff --git a/lib/routes/12306/zxdt.js b/lib/routes/12306/zxdt.js index f5fa807e6f..c9d1dd140f 100644 --- a/lib/routes/12306/zxdt.js +++ b/lib/routes/12306/zxdt.js @@ -63,7 +63,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/21caijing/channel.js b/lib/routes/21caijing/channel.js index ba84e59493..c91a042569 100644 --- a/lib/routes/21caijing/channel.js +++ b/lib/routes/21caijing/channel.js @@ -60,7 +60,7 @@ module.exports = async (ctx) => { description: content, }; - ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/3dm/game.js b/lib/routes/3dm/game.js index ae50c145ff..d615f50879 100644 --- a/lib/routes/3dm/game.js +++ b/lib/routes/3dm/game.js @@ -38,7 +38,7 @@ module.exports = async (ctx) => { link: url, guid: url, }; - ctx.cache.set(url, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/3dm/news_center.js b/lib/routes/3dm/news_center.js index 942cc6bf0c..8b993d46d5 100644 --- a/lib/routes/3dm/news_center.js +++ b/lib/routes/3dm/news_center.js @@ -43,7 +43,7 @@ module.exports = async (ctx) => { guid: itemUrl, }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/99percentinvisible/transcript.js b/lib/routes/99percentinvisible/transcript.js index 50afa1ac3e..31ced49eaa 100644 --- a/lib/routes/99percentinvisible/transcript.js +++ b/lib/routes/99percentinvisible/transcript.js @@ -36,7 +36,7 @@ module.exports = async (ctx) => { description: $('article .transcript-content').html(), pubDate: new Date($('article header .entry-meta time').text()), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/allpoetry/order.js b/lib/routes/allpoetry/order.js index 712645b10e..bac2069652 100644 --- a/lib/routes/allpoetry/order.js +++ b/lib/routes/allpoetry/order.js @@ -46,7 +46,7 @@ module.exports = async (ctx) => { guid: itemUrl, }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/anitama/channel.js b/lib/routes/anitama/channel.js index 26f80822eb..81108ea5ad 100644 --- a/lib/routes/anitama/channel.js +++ b/lib/routes/anitama/channel.js @@ -51,7 +51,7 @@ module.exports = async (ctx) => { description: content.html(), }; - ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/apple/exchange_repair.js b/lib/routes/apple/exchange_repair.js index 371e07d037..29b71d9650 100644 --- a/lib/routes/apple/exchange_repair.js +++ b/lib/routes/apple/exchange_repair.js @@ -57,7 +57,7 @@ module.exports = async (ctx) => { pubDate: new Date(datelist[index].replace(/(\d+) 年 (\d+) 月 (\d+) 日/, '$1-$2-$3')).toISOString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/asahichinese-f/index.js b/lib/routes/asahichinese-f/index.js index a43ef3c71a..9e302e7f2f 100644 --- a/lib/routes/asahichinese-f/index.js +++ b/lib/routes/asahichinese-f/index.js @@ -96,7 +96,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/autotrader/index.js b/lib/routes/autotrader/index.js index d83501e470..73c56c4545 100644 --- a/lib/routes/autotrader/index.js +++ b/lib/routes/autotrader/index.js @@ -62,7 +62,7 @@ module.exports = async (ctx) => { pubDate: new Date().toISOString(), link, }; - ctx.cache.set(link, JSON.stringify(single), 2 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/banyuetan/index.js b/lib/routes/banyuetan/index.js index 287b1b5169..3cd34c192c 100644 --- a/lib/routes/banyuetan/index.js +++ b/lib/routes/banyuetan/index.js @@ -51,7 +51,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/bilibili/cache.js b/lib/routes/bilibili/cache.js index 21c7f1b124..9f3abda460 100644 --- a/lib/routes/bilibili/cache.js +++ b/lib/routes/bilibili/cache.js @@ -20,7 +20,7 @@ module.exports = { }), }); name = nameResponse.data.data.name; - ctx.cache.set(key, name, 24 * 60 * 60); + ctx.cache.set(key, name); } return name; }, @@ -36,7 +36,7 @@ module.exports = { }, }); liveID = liveIDResponse.data.data.room_id; - ctx.cache.set(key, liveID, 24 * 60 * 60); + ctx.cache.set(key, liveID); } return liveID; }, @@ -53,7 +53,7 @@ module.exports = { }, }); name = nameResponse.data.data.info.uname; - ctx.cache.set(key, name, 24 * 60 * 60); + ctx.cache.set(key, name); } return name; }, @@ -71,7 +71,7 @@ module.exports = { const $ = cheerio.load(responseHtml); name = $('title').text(); name = name.substr(0, name.indexOf('_哔哩哔哩')); - ctx.cache.set(key, name, 24 * 60 * 60); + ctx.cache.set(key, name); } return name; }, @@ -95,7 +95,7 @@ module.exports = { } }); } - ctx.cache.set(key, name, 24 * 60 * 60); + ctx.cache.set(key, name); } if (!name) { name = 'Unknown'; @@ -117,7 +117,7 @@ module.exports = { cid = cidResponse.data.data.pages[pid - 1].cid; } if (!cid) { - ctx.cache.set(key, cid, 24 * 60 * 60); + ctx.cache.set(key, cid); } } return cid; diff --git a/lib/routes/bjnews/news.js b/lib/routes/bjnews/news.js index 9bd98734a7..98d50d2919 100644 --- a/lib/routes/bjnews/news.js +++ b/lib/routes/bjnews/news.js @@ -28,7 +28,7 @@ module.exports = async (ctx) => { guid: itemUrl, description: $d('#main .content').html(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/bjp/apod.js b/lib/routes/bjp/apod.js index 488a980971..dc5807f256 100644 --- a/lib/routes/bjp/apod.js +++ b/lib/routes/bjp/apod.js @@ -42,7 +42,7 @@ module.exports = async (ctx) => { link, guid: link, }; - ctx.cache.set(link, JSON.stringify(item), 5 * 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(item)); return Promise.resolve(item); }) diff --git a/lib/routes/cctv/utils/news.js b/lib/routes/cctv/utils/news.js index ac6b9d90d2..debd33d997 100644 --- a/lib/routes/cctv/utils/news.js +++ b/lib/routes/cctv/utils/news.js @@ -86,7 +86,7 @@ module.exports = async (category, ctx) => { } item.description = description; - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } return item; diff --git a/lib/routes/curseforge/files.js b/lib/routes/curseforge/files.js index 506713c384..cc472bd9d9 100644 --- a/lib/routes/curseforge/files.js +++ b/lib/routes/curseforge/files.js @@ -2,7 +2,6 @@ const axios = require('../../utils/axios'); const cheerio = require('cheerio'); const BASE_URL = 'https://minecraft.curseforge.com/'; -const CACHE_TIME = 24 * 60 * 60; module.exports = async (ctx) => { const { project } = ctx.params; @@ -37,7 +36,7 @@ module.exports = async (ctx) => { document.pubDate = new Date(Number($item('.standard-datetime').attr('data-epoch')) * 1000).toUTCString(); document.guid = $item('.md5').text(); - await ctx.cache.set(document.link, JSON.stringify(document), CACHE_TIME); + await ctx.cache.set(document.link, JSON.stringify(document)); return document; }); diff --git a/lib/routes/cyzone/author.js b/lib/routes/cyzone/author.js index b3369a05a7..4dbe98ba4c 100644 --- a/lib/routes/cyzone/author.js +++ b/lib/routes/cyzone/author.js @@ -38,7 +38,7 @@ module.exports = async (ctx) => { } }); item.description = $('.article-content').html(); - ctx.cache.set(key, item.description, 12 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); diff --git a/lib/routes/cyzone/label.js b/lib/routes/cyzone/label.js index 2349a7da74..e187070f94 100644 --- a/lib/routes/cyzone/label.js +++ b/lib/routes/cyzone/label.js @@ -37,7 +37,7 @@ module.exports = async (ctx) => { } }); item.description = $('.article-content').html() || '内容已删除或未通过审核'; - ctx.cache.set(key, item.description, 12 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); diff --git a/lib/routes/d2/daily.js b/lib/routes/d2/daily.js index 569f943a6d..a2fd83681b 100644 --- a/lib/routes/d2/daily.js +++ b/lib/routes/d2/daily.js @@ -48,7 +48,7 @@ module.exports = async (ctx) => { guid: link, link, }; - await ctx.cache.set(link, cache, 24 * 60 * 60); + await ctx.cache.set(link, cache); return item; }); diff --git a/lib/routes/dgtle/trade.js b/lib/routes/dgtle/trade.js index 58be78fcf2..521d8c8251 100644 --- a/lib/routes/dgtle/trade.js +++ b/lib/routes/dgtle/trade.js @@ -57,14 +57,10 @@ module.exports = async (ctx) => { item.description = description; item.pubDate = pubDate; - ctx.cache.set( - key, - { - pubDate, - description, - }, - 24 * 60 * 60 - ); + ctx.cache.set(key, { + pubDate, + description, + }); } return Promise.resolve(item); diff --git a/lib/routes/dongqiudi/daily.js b/lib/routes/dongqiudi/daily.js index ed6660def5..f5d3e225aa 100644 --- a/lib/routes/dongqiudi/daily.js +++ b/lib/routes/dongqiudi/daily.js @@ -54,7 +54,7 @@ module.exports = async (ctx) => { 8 ); - ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i])); } ctx.state.data = { title: '懂球帝早报', diff --git a/lib/routes/dongqiudi/special.js b/lib/routes/dongqiudi/special.js index c66cbd87b9..58bb4da336 100644 --- a/lib/routes/dongqiudi/special.js +++ b/lib/routes/dongqiudi/special.js @@ -54,7 +54,7 @@ module.exports = async (ctx) => { 8 ); - ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i])); } ctx.state.data = { title: `懂球帝专题-${id}`, diff --git a/lib/routes/douban/topic.js b/lib/routes/douban/topic.js index df97da8cef..93ddb814a2 100644 --- a/lib/routes/douban/topic.js +++ b/lib/routes/douban/topic.js @@ -64,7 +64,7 @@ module.exports = async (ctx) => { description: description, }; - ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/duozhi/index.js b/lib/routes/duozhi/index.js index a0cb9861fe..a3f4facfe0 100644 --- a/lib/routes/duozhi/index.js +++ b/lib/routes/duozhi/index.js @@ -47,8 +47,8 @@ module.exports = async (ctx) => { .substr(0, 18) ).toUTCString(); - ctx.cache.set(description_key, single.description, 60 * 60); - ctx.cache.set(pubDate_key, single.pubDate, 60 * 60); + ctx.cache.set(description_key, single.description); + ctx.cache.set(pubDate_key, single.pubDate); } return Promise.resolve(single); diff --git a/lib/routes/dwnews/rank.js b/lib/routes/dwnews/rank.js index 63f1713cea..45e75cee35 100644 --- a/lib/routes/dwnews/rank.js +++ b/lib/routes/dwnews/rank.js @@ -50,7 +50,7 @@ module.exports = async (ctx) => { description: result.description, pubDate: result.pubDate, }; - ctx.cache.set(item.url, JSON.stringify(single), 2 * 60 * 60); + ctx.cache.set(item.url, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/dwnews/yaowen.js b/lib/routes/dwnews/yaowen.js index f024dc436f..2fff6219ef 100644 --- a/lib/routes/dwnews/yaowen.js +++ b/lib/routes/dwnews/yaowen.js @@ -55,7 +55,7 @@ module.exports = async (ctx) => { description, pubDate: pubDate.toUTCString(), }; - ctx.cache.set(item.url, JSON.stringify(single), 2 * 60 * 60); + ctx.cache.set(item.url, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/dytt/index.js b/lib/routes/dytt/index.js index 738dfaecce..42b65d362a 100644 --- a/lib/routes/dytt/index.js +++ b/lib/routes/dytt/index.js @@ -15,7 +15,7 @@ async function load(link, ctx) { const $ = cheerio.load(response.data); const description = $('div#Zoom').html(); - await ctx.cache.set(link, description, 24 * 60 * 60); + await ctx.cache.set(link, description); return description; } diff --git a/lib/routes/embassy/index.js b/lib/routes/embassy/index.js index 04155d03c1..8a7f199f77 100644 --- a/lib/routes/embassy/index.js +++ b/lib/routes/embassy/index.js @@ -55,7 +55,7 @@ module.exports = async (ctx) => { .replace(')', '') ).toUTCString(), }; - ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/gamersky/ent.js b/lib/routes/gamersky/ent.js index 9466c5005b..4f065056e5 100644 --- a/lib/routes/gamersky/ent.js +++ b/lib/routes/gamersky/ent.js @@ -86,7 +86,7 @@ module.exports = async (ctx) => { description: description, pubDate: pubDate, }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/gcores/category.js b/lib/routes/gcores/category.js index d272c51aaa..03c4d10d96 100644 --- a/lib/routes/gcores/category.js +++ b/lib/routes/gcores/category.js @@ -71,7 +71,7 @@ module.exports = async (ctx) => { link: itemUrl, guid: itemUrl, }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/gitea/blog.js b/lib/routes/gitea/blog.js index caffa5559b..3c5d05ff30 100644 --- a/lib/routes/gitea/blog.js +++ b/lib/routes/gitea/blog.js @@ -33,7 +33,7 @@ module.exports = async (ctx) => { $('section .content script').remove(); $('section .content #discourse-comments').remove(); const html = $('section .content').html(); - ctx.cache.set(link, html, 3 * 60 * 60); + ctx.cache.set(link, html); return html; }; diff --git a/lib/routes/gov/mee/gs.js b/lib/routes/gov/mee/gs.js index f571f5efdd..a56ceb3cbd 100644 --- a/lib/routes/gov/mee/gs.js +++ b/lib/routes/gov/mee/gs.js @@ -27,7 +27,7 @@ module.exports = async (ctx) => { const contentData = await axios.get(link); const $content = cheerio.load(contentData.data); description = $content('.TRS_Editor').html(); - ctx.cache.set(key, description, 24 * 60 * 60); + ctx.cache.set(key, description); } const title = $a.text(); diff --git a/lib/routes/gov/zhengce/wenjian.js b/lib/routes/gov/zhengce/wenjian.js index 586c2e7055..22f5f878c0 100644 --- a/lib/routes/gov/zhengce/wenjian.js +++ b/lib/routes/gov/zhengce/wenjian.js @@ -37,7 +37,7 @@ module.exports = async (ctx) => { const contentData = await axios.get(href); const $content = cheerio.load(contentData.data); description = $content('#UCAP-CONTENT').html(); - ctx.cache.set(key, description, 24 * 60 * 60); + ctx.cache.set(key, description); } return { diff --git a/lib/routes/gov/zhengce/zuixin.js b/lib/routes/gov/zhengce/zuixin.js index d3dcf0b49d..681eaf2598 100644 --- a/lib/routes/gov/zhengce/zuixin.js +++ b/lib/routes/gov/zhengce/zuixin.js @@ -24,7 +24,7 @@ module.exports = async (ctx) => { const contentData = await axios.get(href.startsWith('/zhengce') ? `http://www.gov.cn${href}` : href); const $content = cheerio.load(contentData.data); description = $content('#UCAP-CONTENT').html(); - ctx.cache.set(key, description, 24 * 60 * 60); + ctx.cache.set(key, description); } return { diff --git a/lib/routes/hexo/next.js b/lib/routes/hexo/next.js index 947232ba1b..131c764bbc 100644 --- a/lib/routes/hexo/next.js +++ b/lib/routes/hexo/next.js @@ -31,7 +31,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); item.pubDate = $('time').attr('datetime'); item.description = $('.post-body').html(); - ctx.cache.set(key, item.description, 6 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); }) diff --git a/lib/routes/hko/weather.js b/lib/routes/hko/weather.js index 19c81d0879..14f48ede38 100644 --- a/lib/routes/hko/weather.js +++ b/lib/routes/hko/weather.js @@ -43,7 +43,7 @@ module.exports = async (ctx) => { item: items, }; // one hour cache - ctx.cache.set(url, JSON.stringify(result), 60 * 60); + ctx.cache.set(url, JSON.stringify(result)); ctx.state.data = result; }; diff --git a/lib/routes/hupu/bbs.js b/lib/routes/hupu/bbs.js index f2c0c92654..d4527eda78 100644 --- a/lib/routes/hupu/bbs.js +++ b/lib/routes/hupu/bbs.js @@ -76,7 +76,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/huxiu/utils.js b/lib/routes/huxiu/utils.js index efa1fcbffc..121997b75f 100644 --- a/lib/routes/huxiu/utils.js +++ b/lib/routes/huxiu/utils.js @@ -10,26 +10,22 @@ const ProcessFeed = async (list, cache) => { list.map(async (e) => { const link = url.resolve(host, e); - const single = await cache.tryGet( - link, - async () => { - const response = await axios.get(link); + const single = await cache.tryGet(link, async () => { + const response = await axios.get(link); - const $ = cheerio.load(response.data); - $('.neirong-shouquan, .neirong-shouquan-public').remove(); + const $ = cheerio.load(response.data); + $('.neirong-shouquan, .neirong-shouquan-public').remove(); - return { - title: $('.t-h1') - .text() - .trim(), - description: $('.article-img-box').html() + $('.article-content-wrap').html(), - pubDate: date($('.article-time').text(), 8), - author: $('.article-author .author-name').text(), - link, - }; - }, - 2 * 24 * 60 * 60 - ); + return { + title: $('.t-h1') + .text() + .trim(), + description: $('.article-img-box').html() + $('.article-content-wrap').html(), + pubDate: date($('.article-time').text(), 8), + author: $('.article-author .author-name').text(), + link, + }; + }); return Promise.resolve(single); }) diff --git a/lib/routes/ifanr/index.js b/lib/routes/ifanr/index.js index e2878534fb..01f1ae822e 100644 --- a/lib/routes/ifanr/index.js +++ b/lib/routes/ifanr/index.js @@ -62,7 +62,7 @@ module.exports = async (ctx) => { item.title = $('.c-dasheng_header__title').text(); } - ctx.cache.set(itemUrl, JSON.stringify(item), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/imaijia/category.js b/lib/routes/imaijia/category.js index 7e5dd5a5fe..208d181352 100644 --- a/lib/routes/imaijia/category.js +++ b/lib/routes/imaijia/category.js @@ -50,7 +50,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(pubDate).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/infoq/utils.js b/lib/routes/infoq/utils.js index 686413bc25..4b56fb0f33 100644 --- a/lib/routes/infoq/utils.js +++ b/lib/routes/infoq/utils.js @@ -6,37 +6,33 @@ const ProcessFeed = async (list, cache) => { const items = await Promise.all( list.map(async (e) => { const uuid = e.uuid; - const single = await cache.tryGet( - uuid, - async () => { - const link = `https://www.infoq.cn/article/${uuid}`; - const resp = await axios({ - method: 'post', - url: detailUrl, - headers: { - Referer: link, - 'Content-Type': 'application/json', - }, - data: { - uuid: uuid, - }, - }); + const single = await cache.tryGet(uuid, async () => { + const link = `https://www.infoq.cn/article/${uuid}`; + const resp = await axios({ + method: 'post', + url: detailUrl, + headers: { + Referer: link, + 'Content-Type': 'application/json', + }, + data: { + uuid: uuid, + }, + }); - const data = resp.data.data; - const author = data.author ? data.author.map((p) => p.nickname).join(',') : data.no_author; - const pubDate = new Date(); - pubDate.setTime(data.publish_time); + const data = resp.data.data; + const author = data.author ? data.author.map((p) => p.nickname).join(',') : data.no_author; + const pubDate = new Date(); + pubDate.setTime(data.publish_time); - return { - title: data.article_title, - description: data.content, - pubDate, - author: author, - link, - }; - }, - 2 * 24 * 60 * 60 - ); + return { + title: data.article_title, + description: data.content, + pubDate, + author: author, + link, + }; + }); return Promise.resolve(single); }) diff --git a/lib/routes/infzm/news.js b/lib/routes/infzm/news.js index 5667712c1c..0027a0c0bc 100644 --- a/lib/routes/infzm/news.js +++ b/lib/routes/infzm/news.js @@ -47,7 +47,7 @@ module.exports = async (ctx) => { description = $('#content').html(); } - ctx.cache.set(key, description, 24 * 60 * 60); + ctx.cache.set(key, description); } return { diff --git a/lib/routes/instagram/tag.js b/lib/routes/instagram/tag.js index 6e7bd29954..d288ca53a4 100644 --- a/lib/routes/instagram/tag.js +++ b/lib/routes/instagram/tag.js @@ -33,7 +33,7 @@ module.exports = async (ctx) => { image: item.display_url, }; - ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify([single])); return Promise.resolve([single]); } else if (item.__typename === 'GraphSidecar') { const response = await axios({ @@ -46,7 +46,7 @@ module.exports = async (ctx) => { video: item.node.video_url, })); - ctx.cache.set(url, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify(single)); return Promise.resolve(single); } else if (item.__typename === 'GraphVideo') { const response = await axios({ @@ -59,7 +59,7 @@ module.exports = async (ctx) => { video: data.entry_data.PostPage[0].graphql.shortcode_media.video_url, }; - ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify([single])); return Promise.resolve([single]); } }) diff --git a/lib/routes/instagram/user.js b/lib/routes/instagram/user.js index 20fd87802e..caf9d0accf 100644 --- a/lib/routes/instagram/user.js +++ b/lib/routes/instagram/user.js @@ -34,7 +34,7 @@ module.exports = async (ctx) => { image: item.display_url, }; - ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify([single])); return Promise.resolve([single]); } else if (item.__typename === 'GraphSidecar') { const response = await axios({ @@ -47,7 +47,7 @@ module.exports = async (ctx) => { video: item.node.video_url, })); - ctx.cache.set(url, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify(single)); return Promise.resolve(single); } else if (item.__typename === 'GraphVideo') { const response = await axios({ @@ -60,7 +60,7 @@ module.exports = async (ctx) => { video: data.entry_data.PostPage[0].graphql.shortcode_media.video_url, }; - ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify([single])); return Promise.resolve([single]); } }) diff --git a/lib/routes/iresearch/report.js b/lib/routes/iresearch/report.js index 60aa901844..509315d9d8 100644 --- a/lib/routes/iresearch/report.js +++ b/lib/routes/iresearch/report.js @@ -24,7 +24,7 @@ async function processReport(item, ctx) { description += `
`; } - await ctx.cache.set(apiUrl, description, 24 * 60 * 60); + await ctx.cache.set(apiUrl, description); return description; } diff --git a/lib/routes/javbus/util.js b/lib/routes/javbus/util.js index 312ac2d70e..fedd5aa644 100644 --- a/lib/routes/javbus/util.js +++ b/lib/routes/javbus/util.js @@ -142,7 +142,7 @@ const getDetail = async (link, ctx) => { screenData = null; } const detail = { actresses, filmTime, filmLast, filmEstabName, filmMakerbName, seriesName, directorName, code, screenData }; - ctx.cache.set(link, JSON.stringify(detail), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(detail)); return detail; } }; diff --git a/lib/routes/jiemian/list.js b/lib/routes/jiemian/list.js index 2db94be894..9e4446050c 100644 --- a/lib/routes/jiemian/list.js +++ b/lib/routes/jiemian/list.js @@ -50,7 +50,7 @@ module.exports = async (ctx) => { const content = $('.article-view .article-main').html(); out[indexList[i]].description = content; - ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i])); } ctx.state.data = { title: $('title').text(), diff --git a/lib/routes/jike/topic.js b/lib/routes/jike/topic.js index b174e38758..796c27bfdb 100644 --- a/lib/routes/jike/topic.js +++ b/lib/routes/jike/topic.js @@ -55,7 +55,7 @@ module.exports = async (ctx) => { } if (description) { item.description = description; - await ctx.cache.set(newsUrl, description, 24 * 60 * 60); + await ctx.cache.set(newsUrl, description); } } } diff --git a/lib/routes/juesheng/index.js b/lib/routes/juesheng/index.js index 111848ca3c..81413367cf 100644 --- a/lib/routes/juesheng/index.js +++ b/lib/routes/juesheng/index.js @@ -45,8 +45,8 @@ module.exports = async (ctx) => { .text() ).toUTCString(); - ctx.cache.set(description_key, single.description, 60 * 60); - ctx.cache.set(pubDate_key, single.pubDate, 60 * 60); + ctx.cache.set(description_key, single.description); + ctx.cache.set(pubDate_key, single.pubDate); } return Promise.resolve(single); diff --git a/lib/routes/kpmg/insights.js b/lib/routes/kpmg/insights.js index b41efaa404..7163db9846 100644 --- a/lib/routes/kpmg/insights.js +++ b/lib/routes/kpmg/insights.js @@ -40,7 +40,7 @@ module.exports = async (ctx) => { link: itemUrl, description: description, }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/leetcode/articles.js b/lib/routes/leetcode/articles.js index 6ed0d7b320..e130a7659d 100644 --- a/lib/routes/leetcode/articles.js +++ b/lib/routes/leetcode/articles.js @@ -58,7 +58,7 @@ module.exports = async (ctx) => { pubDate: new Date(info.date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/matters/author.js b/lib/routes/matters/author.js index 3a394ac450..ad0496bf62 100644 --- a/lib/routes/matters/author.js +++ b/lib/routes/matters/author.js @@ -38,7 +38,7 @@ module.exports = async (ctx) => { const res = responses[i]; const $ = cheerio.load(res.data); out[indexList[i]].description = $('.u-content').html(); - ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i])); } ctx.state.data = { title: $('title').text(), diff --git a/lib/routes/matters/hot.js b/lib/routes/matters/hot.js index 535f80f796..86b13a5028 100644 --- a/lib/routes/matters/hot.js +++ b/lib/routes/matters/hot.js @@ -38,7 +38,7 @@ module.exports = async (ctx) => { const res = responses[i]; const $ = cheerio.load(res.data); out[indexList[i]].description = $('.u-content').html(); - ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i])); } ctx.state.data = { title: $('title').text(), diff --git a/lib/routes/matters/latest.js b/lib/routes/matters/latest.js index 6606bddad8..a75efe77af 100644 --- a/lib/routes/matters/latest.js +++ b/lib/routes/matters/latest.js @@ -33,7 +33,7 @@ module.exports = async (ctx) => { description: article, }; - ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/matters/tags.js b/lib/routes/matters/tags.js index e62424f1b7..4c12a1ac8f 100644 --- a/lib/routes/matters/tags.js +++ b/lib/routes/matters/tags.js @@ -38,7 +38,7 @@ module.exports = async (ctx) => { const res = responses[i]; const $ = cheerio.load(res.data); out[indexList[i]].description = $('.u-content').html(); - ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i])); } ctx.state.data = { title: $('title').text(), diff --git a/lib/routes/matters/topics.js b/lib/routes/matters/topics.js index 30027e0528..b3f0d05967 100644 --- a/lib/routes/matters/topics.js +++ b/lib/routes/matters/topics.js @@ -38,7 +38,7 @@ module.exports = async (ctx) => { const res = responses[i]; const $ = cheerio.load(res.data); out[indexList[i]].description = $('.u-content').html(); - ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i])); } ctx.state.data = { title: $('title').text(), diff --git a/lib/routes/miui/index.js b/lib/routes/miui/index.js index 68356e4e79..853d313587 100644 --- a/lib/routes/miui/index.js +++ b/lib/routes/miui/index.js @@ -1,7 +1,6 @@ const axios = require('../../utils/axios'); const cacheLength = 5; -const cacheDays = 30; module.exports = async (ctx) => { const { type = 'release', device, region = 'cn' } = ctx.params; @@ -48,7 +47,7 @@ module.exports = async (ctx) => { ...oldPosts, ]; - await ctx.cache.set(cacheName, item.slice(0, cacheLength), cacheDays * 24 * 60 * 60); + await ctx.cache.set(cacheName, item.slice(0, cacheLength)); } ctx.state.data = { diff --git a/lib/routes/mp4ba/index.js b/lib/routes/mp4ba/index.js index b55c51fe88..032b266a22 100644 --- a/lib/routes/mp4ba/index.js +++ b/lib/routes/mp4ba/index.js @@ -94,7 +94,7 @@ async function buildRss($, paramType, ctx) { description = $page('.main') .find('.intro') .html(); - cache.set(key, description, 24 * 60 * 60); + cache.set(key, description); } } diff --git a/lib/routes/mpaypass/news.js b/lib/routes/mpaypass/news.js index 086246e62e..b4ac3fb4c4 100644 --- a/lib/routes/mpaypass/news.js +++ b/lib/routes/mpaypass/news.js @@ -30,7 +30,7 @@ module.exports = async (ctx) => { const contentData = await axios.get(href); const $content = cheerio.load(contentData.data); description = $content('.newsbody').html(); - ctx.cache.set(key, description, 24 * 60 * 60); + ctx.cache.set(key, description); } return { diff --git a/lib/routes/namoc/announcement.js b/lib/routes/namoc/announcement.js index b34279a9aa..00dbe24e98 100644 --- a/lib/routes/namoc/announcement.js +++ b/lib/routes/namoc/announcement.js @@ -60,7 +60,7 @@ module.exports = async (ctx) => { .text() .replace('时间:', '') ).toUTCString(); - ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[i].link, JSON.stringify(out[i])); } ctx.state.data = { title: '中国美术馆 -- 通知公告', diff --git a/lib/routes/namoc/exhibition.js b/lib/routes/namoc/exhibition.js index 2db52ab5f0..1ba448f2a8 100644 --- a/lib/routes/namoc/exhibition.js +++ b/lib/routes/namoc/exhibition.js @@ -78,7 +78,7 @@ module.exports = async (ctx) => { .text() .replace('时间:', '') ).toUTCString(); - ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[i].link, JSON.stringify(out[i])); } ctx.state.data = { title: '中国美术馆 -- 展览预告', diff --git a/lib/routes/namoc/media.js b/lib/routes/namoc/media.js index 75d9d2675f..6ffcf8eb2f 100644 --- a/lib/routes/namoc/media.js +++ b/lib/routes/namoc/media.js @@ -65,7 +65,7 @@ module.exports = async (ctx) => { .text() .replace('时间:', '') ).toUTCString(); - ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[i].link, JSON.stringify(out[i])); } } ctx.state.data = { diff --git a/lib/routes/namoc/news.js b/lib/routes/namoc/news.js index 2fc181035a..d1528efbce 100644 --- a/lib/routes/namoc/news.js +++ b/lib/routes/namoc/news.js @@ -65,7 +65,7 @@ module.exports = async (ctx) => { .text() .replace('时间:', '') ).toUTCString(); - ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[i].link, JSON.stringify(out[i])); } } ctx.state.data = { diff --git a/lib/routes/natgeo/natgeo.js b/lib/routes/natgeo/natgeo.js index 59e12383a7..aca53ed352 100644 --- a/lib/routes/natgeo/natgeo.js +++ b/lib/routes/natgeo/natgeo.js @@ -32,7 +32,7 @@ module.exports = async (ctx) => { const data = storyDetail.data; const $ = cheerio.load(data); item.description = $('.td-post-content').html(); - ctx.cache.set(key, item.description, 12 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); }) diff --git a/lib/routes/nhentai/util.js b/lib/routes/nhentai/util.js index 70cdb45aba..a9a8ae0b82 100644 --- a/lib/routes/nhentai/util.js +++ b/lib/routes/nhentai/util.js @@ -12,7 +12,7 @@ exports.getSimple = async (url) => { }; const MAX_DETAIL = 5; -exports.getDetails = async (cache, simples) => Promise.all(simples.slice(0, MAX_DETAIL).map((simple) => cache.tryGet(simple.link, () => getDetail(simple), 24 * 60 * 60))); +exports.getDetails = async (cache, simples) => Promise.all(simples.slice(0, MAX_DETAIL).map((simple) => cache.tryGet(simple.link, () => getDetail(simple)))); const parseSimpleDetail = ($ele) => { const link = resolve('https://nhentai.net', $ele.attr('href')); diff --git a/lib/routes/novel/wenxuemi.js b/lib/routes/novel/wenxuemi.js index 5f03f3a2d1..6e5750ce03 100644 --- a/lib/routes/novel/wenxuemi.js +++ b/lib/routes/novel/wenxuemi.js @@ -47,7 +47,7 @@ module.exports = async (ctx) => { link: link, }; if (res.slice(0, 10).includes('正在手打中') === false) { - ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(resultItem)); } } diff --git a/lib/routes/nowcoder/discuss.js b/lib/routes/nowcoder/discuss.js index f3a6d4ef1e..fa521cbbc1 100644 --- a/lib/routes/nowcoder/discuss.js +++ b/lib/routes/nowcoder/discuss.js @@ -61,7 +61,7 @@ module.exports = async (ctx) => { description: description, pubDate: date(date_value, 8), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/oschina/news.js b/lib/routes/oschina/news.js index 069c4fcf70..173072d329 100644 --- a/lib/routes/oschina/news.js +++ b/lib/routes/oschina/news.js @@ -84,7 +84,7 @@ module.exports = async (ctx) => { item.author = content('a.__user') .find('span') .text(); - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } } return Promise.resolve(item); diff --git a/lib/routes/oschina/u.js b/lib/routes/oschina/u.js index 6eea6e0649..ef7ba65d00 100644 --- a/lib/routes/oschina/u.js +++ b/lib/routes/oschina/u.js @@ -43,7 +43,7 @@ module.exports = async (ctx) => { const content = cheerio.load(detail.data); content('.ad-wrap').remove(); item.description = content('#articleContent').html(); - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); }) diff --git a/lib/routes/oschina/user.js b/lib/routes/oschina/user.js index fb3c668f8e..8752802073 100644 --- a/lib/routes/oschina/user.js +++ b/lib/routes/oschina/user.js @@ -43,7 +43,7 @@ module.exports = async (ctx) => { const content = cheerio.load(detail.data); content('.ad-wrap').remove(); item.description = content('#articleContent').html(); - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); }) diff --git a/lib/routes/parcel/hermesuk.js b/lib/routes/parcel/hermesuk.js index df54a3a25e..8aaa63adb3 100644 --- a/lib/routes/parcel/hermesuk.js +++ b/lib/routes/parcel/hermesuk.js @@ -39,7 +39,7 @@ module.exports = async (ctx) => { }; } - await ctx.cache.set(tracking, JSON.stringify(single), 1 * 60 * 60); + await ctx.cache.set(tracking, JSON.stringify(single)); } ctx.state.data = { diff --git a/lib/routes/patchwork.kernel.org/cache.js b/lib/routes/patchwork.kernel.org/cache.js index 58b4da6142..59696f0c8d 100644 --- a/lib/routes/patchwork.kernel.org/cache.js +++ b/lib/routes/patchwork.kernel.org/cache.js @@ -10,7 +10,7 @@ module.exports = { url: `https://patchwork.kernel.org/api/patches/${id}/`, }); name = patchDetail.data.name; - ctx.cache.set(key, name, 24 * 60 * 60); + ctx.cache.set(key, name); } return name; }, diff --git a/lib/routes/pediy/topic.js b/lib/routes/pediy/topic.js index 7a559503c8..853cdbc77f 100644 --- a/lib/routes/pediy/topic.js +++ b/lib/routes/pediy/topic.js @@ -98,7 +98,7 @@ module.exports = async (ctx) => { .eq(0) .find('.message') .html(); - ctx.cache.set(key, description, 24 * 60 * 60); + ctx.cache.set(key, description); } return Promise.resolve({ diff --git a/lib/routes/people/opinion.js b/lib/routes/people/opinion.js index f3206b6aee..11954a3214 100644 --- a/lib/routes/people/opinion.js +++ b/lib/routes/people/opinion.js @@ -64,7 +64,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/people/xjpjh.js b/lib/routes/people/xjpjh.js index e669d8d7cf..30ce0be52b 100644 --- a/lib/routes/people/xjpjh.js +++ b/lib/routes/people/xjpjh.js @@ -61,7 +61,7 @@ module.exports = async (ctx) => { link: itemUrl, description: description, }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/qdaily/category.js b/lib/routes/qdaily/category.js index b706344807..bff3ac785b 100644 --- a/lib/routes/qdaily/category.js +++ b/lib/routes/qdaily/category.js @@ -49,7 +49,7 @@ module.exports = async (ctx) => { $('.article-detail-ft').remove(); out[indexList[i]].description = $('.main .com-article-detail').html(); - ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i])); } ctx.state.data = { title: $('title').text(), diff --git a/lib/routes/qdaily/column.js b/lib/routes/qdaily/column.js index da5ec82cbc..34c4e680f4 100644 --- a/lib/routes/qdaily/column.js +++ b/lib/routes/qdaily/column.js @@ -50,7 +50,7 @@ module.exports = async (ctx) => { $('.article-detail-ft').remove(); out[indexList[i]].description = $('.main .com-article-detail').html(); - ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i])); } ctx.state.data = { title: $('title').text(), diff --git a/lib/routes/qdaily/tag.js b/lib/routes/qdaily/tag.js index 04fbf5c9ec..0878a1fa9f 100644 --- a/lib/routes/qdaily/tag.js +++ b/lib/routes/qdaily/tag.js @@ -49,7 +49,7 @@ module.exports = async (ctx) => { $('.article-detail-ft').remove(); out[indexList[i]].description = $('.main .com-article-detail').html(); - ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); + ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i])); } ctx.state.data = { title: $('title').text(), diff --git a/lib/routes/qtfyfl/category.js b/lib/routes/qtfyfl/category.js index 6b55a7bace..860b2a89c1 100644 --- a/lib/routes/qtfyfl/category.js +++ b/lib/routes/qtfyfl/category.js @@ -88,7 +88,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/qutoutiao/category.js b/lib/routes/qutoutiao/category.js index 1e9e10b631..a6d01db369 100644 --- a/lib/routes/qutoutiao/category.js +++ b/lib/routes/qutoutiao/category.js @@ -30,7 +30,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date * 1000).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/readhub/category.js b/lib/routes/readhub/category.js index 8cd2ba43a0..f7121f711b 100644 --- a/lib/routes/readhub/category.js +++ b/lib/routes/readhub/category.js @@ -79,7 +79,7 @@ module.exports = async (ctx) => { link, }; - await ctx.cache.set(link, JSON.stringify(item), 24 * 60 * 60); + await ctx.cache.set(link, JSON.stringify(item)); } else { const description = news.summaryAuto || news.summary || news.title; item = { diff --git a/lib/routes/segmentfault/channel.js b/lib/routes/segmentfault/channel.js index ecd8035fc2..fb4c23a1a4 100644 --- a/lib/routes/segmentfault/channel.js +++ b/lib/routes/segmentfault/channel.js @@ -91,7 +91,7 @@ module.exports = async (ctx) => { description: description, pubDate: date(date_value, 8), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/sexinsex/index.js b/lib/routes/sexinsex/index.js index b0bec05c14..07f8321b7a 100644 --- a/lib/routes/sexinsex/index.js +++ b/lib/routes/sexinsex/index.js @@ -87,7 +87,7 @@ module.exports = async (ctx) => { } catch (err) { return Promise.resolve(''); } - ctx.cache.set(link, JSON.stringify(single), 3 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/sina/rollnews.js b/lib/routes/sina/rollnews.js index 59128a45aa..63884ee21c 100644 --- a/lib/routes/sina/rollnews.js +++ b/lib/routes/sina/rollnews.js @@ -11,16 +11,12 @@ module.exports = async (ctx) => { const date = data.intime * 1000; const link = data.url; - const description = await ctx.cache.tryGet( - `sina-rollnews: ${link}`, - async () => { - const response = await axios.get(link); - const $ = cheerio.load(response.data); + const description = await ctx.cache.tryGet(`sina-rollnews: ${link}`, async () => { + const response = await axios.get(link); + const $ = cheerio.load(response.data); - return $('.article').html(); - }, - 3 * 60 * 60 - ); + return $('.article').html(); + }); const single = { title: title, diff --git a/lib/routes/smzdm/haowen.js b/lib/routes/smzdm/haowen.js index 6042fe9916..9fe2459e55 100644 --- a/lib/routes/smzdm/haowen.js +++ b/lib/routes/smzdm/haowen.js @@ -49,7 +49,7 @@ module.exports = async (ctx) => { description: description, pubDate: date(pubdate), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/sspai/column.js b/lib/routes/sspai/column.js index 7e03b483b3..9974eab412 100644 --- a/lib/routes/sspai/column.js +++ b/lib/routes/sspai/column.js @@ -52,7 +52,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date * 1000).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/sspai/matrix.js b/lib/routes/sspai/matrix.js index 15e1f464e3..6e0231c39e 100644 --- a/lib/routes/sspai/matrix.js +++ b/lib/routes/sspai/matrix.js @@ -22,7 +22,7 @@ module.exports = async (ctx) => { const response = await axios({ method: 'get', url: link }); const $ = cheerio.load(response.data); description = $('#article-content > div').html(); - ctx.cache.set(key, description, 24 * 60 * 60); + ctx.cache.set(key, description); } return { diff --git a/lib/routes/t66y/index.js b/lib/routes/t66y/index.js index 96cd6898e0..8c0f8b0ded 100644 --- a/lib/routes/t66y/index.js +++ b/lib/routes/t66y/index.js @@ -160,7 +160,7 @@ module.exports = async (ctx) => { } catch (err) { return Promise.resolve(''); } - ctx.cache.set(link, JSON.stringify(single), 3 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/t66y/post.js b/lib/routes/t66y/post.js index 1e4452b082..af3d39330e 100644 --- a/lib/routes/t66y/post.js +++ b/lib/routes/t66y/post.js @@ -148,7 +148,7 @@ module.exports = async (ctx) => { }); // 记录读取的最后页码 - ctx.cache.set(`/t66y/post/${tid}`, JSON.stringify({ page }), 3 * 60 * 60); + ctx.cache.set(`/t66y/post/${tid}`, JSON.stringify({ page })); // 如果没有读到内容,则读取下一页,最多读取3页 if (items.length === 0 && retry < 3) { diff --git a/lib/routes/tencent/dajia/author.js b/lib/routes/tencent/dajia/author.js index d253709b41..f6e89e2d8a 100644 --- a/lib/routes/tencent/dajia/author.js +++ b/lib/routes/tencent/dajia/author.js @@ -38,7 +38,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/tencent/dajia/index.js b/lib/routes/tencent/dajia/index.js index a8a581a9db..00cebbf765 100644 --- a/lib/routes/tencent/dajia/index.js +++ b/lib/routes/tencent/dajia/index.js @@ -51,7 +51,7 @@ module.exports = async (ctx) => { }); item.description = $('#articleContent').html(); - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); diff --git a/lib/routes/tencent/dajia/zhuanlan.js b/lib/routes/tencent/dajia/zhuanlan.js index 7f462daae1..e875b91f12 100644 --- a/lib/routes/tencent/dajia/zhuanlan.js +++ b/lib/routes/tencent/dajia/zhuanlan.js @@ -40,7 +40,7 @@ module.exports = async (ctx) => { author: author, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/tencent/gameinstitute/community.js b/lib/routes/tencent/gameinstitute/community.js index f481923731..f909440c9d 100644 --- a/lib/routes/tencent/gameinstitute/community.js +++ b/lib/routes/tencent/gameinstitute/community.js @@ -44,7 +44,7 @@ module.exports = async (ctx) => { }); item.description = $('.art-cont').html(); - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); diff --git a/lib/routes/tencent/guyu/channel.js b/lib/routes/tencent/guyu/channel.js index 256a4156ab..70f675d403 100644 --- a/lib/routes/tencent/guyu/channel.js +++ b/lib/routes/tencent/guyu/channel.js @@ -53,7 +53,7 @@ module.exports = async (ctx) => { author: author, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/tencent/wechat/miniprogram/plugins.js b/lib/routes/tencent/wechat/miniprogram/plugins.js index f9fc985026..0da7ad22c1 100644 --- a/lib/routes/tencent/wechat/miniprogram/plugins.js +++ b/lib/routes/tencent/wechat/miniprogram/plugins.js @@ -44,7 +44,7 @@ module.exports = async (ctx) => { }); item.description = $(`#${id}`).html(); - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); diff --git a/lib/routes/ui-cn/article.js b/lib/routes/ui-cn/article.js index 7020c3c9ab..dec5f89055 100644 --- a/lib/routes/ui-cn/article.js +++ b/lib/routes/ui-cn/article.js @@ -51,8 +51,8 @@ module.exports = async (ctx) => { .replace(/更新于:/g, '') ).toUTCString(); - ctx.cache.set(description_key, single.description, 60 * 60); - ctx.cache.set(pubDate_key, single.pubDate, 60 * 60); + ctx.cache.set(description_key, single.description); + ctx.cache.set(pubDate_key, single.pubDate); } return Promise.resolve(single); diff --git a/lib/routes/ui-cn/user.js b/lib/routes/ui-cn/user.js index 8c751f1226..2c66020504 100644 --- a/lib/routes/ui-cn/user.js +++ b/lib/routes/ui-cn/user.js @@ -50,8 +50,8 @@ module.exports = async (ctx) => { .replace(/更新于:/g, '') ).toUTCString(); - ctx.cache.set(description_key, single.description, 60 * 60); - ctx.cache.set(pubDate_key, single.pubDate, 60 * 60); + ctx.cache.set(description_key, single.description); + ctx.cache.set(pubDate_key, single.pubDate); } return Promise.resolve(single); diff --git a/lib/routes/universities/cas/sim/academic.js b/lib/routes/universities/cas/sim/academic.js index 1bd1e09655..349c6f854f 100644 --- a/lib/routes/universities/cas/sim/academic.js +++ b/lib/routes/universities/cas/sim/academic.js @@ -57,7 +57,7 @@ module.exports = async (ctx) => { .trim(), pubDate: new Date(item.date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/cqu/jwc/announcement.js b/lib/routes/universities/cqu/jwc/announcement.js index 24e3eda101..803c9ca9ce 100644 --- a/lib/routes/universities/cqu/jwc/announcement.js +++ b/lib/routes/universities/cqu/jwc/announcement.js @@ -2,7 +2,6 @@ const axios = require('../../../../utils/axios'); const cheerio = require('cheerio'); const baseUrl = 'http://jwc.cqu.edu.cn'; -const cacheTime = 24 * 60 * 60; module.exports = async (ctx) => { const response = await axios({ @@ -48,7 +47,7 @@ module.exports = async (ctx) => { $('div .field-items') .find('p') .text(); - await ctx.cache.set(item.link, JSON.stringify(item), cacheTime); + await ctx.cache.set(item.link, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/universities/cuit/cxxww.js b/lib/routes/universities/cuit/cxxww.js index 63835e7e47..ccacc7107d 100644 --- a/lib/routes/universities/cuit/cxxww.js +++ b/lib/routes/universities/cuit/cxxww.js @@ -56,7 +56,7 @@ module.exports = async (ctx) => { .replace('/', '-') ).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); // + ctx.cache.set(itemUrl, JSON.stringify(single)); // return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/heu/ugs/news.js b/lib/routes/universities/heu/ugs/news.js index b3e5acc54c..5e8715ef19 100644 --- a/lib/routes/universities/heu/ugs/news.js +++ b/lib/routes/universities/heu/ugs/news.js @@ -100,7 +100,7 @@ module.exports = async (ctx) => { .trim(), pubDate: dateList[index], }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); } else { const single = { diff --git a/lib/routes/universities/hit/today.js b/lib/routes/universities/hit/today.js index ab206a2a87..2b90bcf41b 100644 --- a/lib/routes/universities/hit/today.js +++ b/lib/routes/universities/hit/today.js @@ -51,7 +51,7 @@ module.exports = async (ctx) => { title: title, description: '请进行统一身份认证后查看全文', }; - ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); } @@ -64,7 +64,7 @@ module.exports = async (ctx) => { description: $('.article-content').text(), }; - ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/mit/graduateadmissions.js b/lib/routes/universities/mit/graduateadmissions.js index f87bb51c03..a84fc6e58f 100644 --- a/lib/routes/universities/mit/graduateadmissions.js +++ b/lib/routes/universities/mit/graduateadmissions.js @@ -51,7 +51,7 @@ module.exports = async (ctx) => { author: author, description: description, }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) .get() diff --git a/lib/routes/universities/njupt/jwc.js b/lib/routes/universities/njupt/jwc.js index ed964085a7..cf69c58a5b 100644 --- a/lib/routes/universities/njupt/jwc.js +++ b/lib/routes/universities/njupt/jwc.js @@ -67,7 +67,7 @@ module.exports = async (ctx) => { .replace('发布时间:', '') ).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); } else { const single = { diff --git a/lib/routes/universities/nuaa/cs/index.js b/lib/routes/universities/nuaa/cs/index.js index 81e4e1cf27..76095df529 100644 --- a/lib/routes/universities/nuaa/cs/index.js +++ b/lib/routes/universities/nuaa/cs/index.js @@ -70,7 +70,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/nuist/cas.js b/lib/routes/universities/nuist/cas.js index cbdc2bf797..e01269fd26 100644 --- a/lib/routes/universities/nuist/cas.js +++ b/lib/routes/universities/nuist/cas.js @@ -71,7 +71,7 @@ module.exports = async (ctx) => { .replace('作者:', ''); item.description = article.find('.xwco').html(); - await ctx.cache.set(item.link, JSON.stringify(item), 24 * 60 * 60); + await ctx.cache.set(item.link, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/universities/nuist/jwc.js b/lib/routes/universities/nuist/jwc.js index a1ed6ad624..ed939c301d 100644 --- a/lib/routes/universities/nuist/jwc.js +++ b/lib/routes/universities/nuist/jwc.js @@ -63,7 +63,7 @@ module.exports = async (ctx) => { item.description = article.find('.xwco').html(); item.category = map[category]; - await ctx.cache.set(item.link, JSON.stringify(item), 24 * 60 * 60); + await ctx.cache.set(item.link, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/universities/nuist/scs.js b/lib/routes/universities/nuist/scs.js index 32db1e6d46..6f1ae5b85d 100644 --- a/lib/routes/universities/nuist/scs.js +++ b/lib/routes/universities/nuist/scs.js @@ -49,7 +49,7 @@ module.exports = async (ctx) => { item.description = $('.wp_articlecontent').html(); item.category = map[category]; - await ctx.cache.set(item.link, JSON.stringify(item), 24 * 60 * 60); + await ctx.cache.set(item.link, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/universities/nuist/sese.js b/lib/routes/universities/nuist/sese.js index a95834fb08..a88eb67052 100644 --- a/lib/routes/universities/nuist/sese.js +++ b/lib/routes/universities/nuist/sese.js @@ -55,7 +55,7 @@ module.exports = async (ctx) => { .text(); item.description = article.find('.xwco').html(); - await ctx.cache.set(item.link, JSON.stringify(item), 24 * 60 * 60); + await ctx.cache.set(item.link, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/universities/nuist/xgc.js b/lib/routes/universities/nuist/xgc.js index 64d7b11e5a..9ee2e33961 100644 --- a/lib/routes/universities/nuist/xgc.js +++ b/lib/routes/universities/nuist/xgc.js @@ -43,7 +43,7 @@ module.exports = async (ctx) => { ).toUTCString(); item.description = $('.wp_articlecontent ').html(); - await ctx.cache.set(item.link, JSON.stringify(item), 24 * 60 * 60); + await ctx.cache.set(item.link, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/universities/nuist/yjs.js b/lib/routes/universities/nuist/yjs.js index ef4538ce62..4dff9e3b33 100644 --- a/lib/routes/universities/nuist/yjs.js +++ b/lib/routes/universities/nuist/yjs.js @@ -58,7 +58,7 @@ module.exports = async (ctx) => { item.description = article.find('.xwco').html(); item.category = map[category]; - await ctx.cache.set(item.link, JSON.stringify(item), 24 * 60 * 60); + await ctx.cache.set(item.link, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/universities/scut/jwc.js b/lib/routes/universities/scut/jwc.js index 0cb94844aa..959db3c675 100644 --- a/lib/routes/universities/scut/jwc.js +++ b/lib/routes/universities/scut/jwc.js @@ -57,7 +57,7 @@ module.exports = async (ctx) => { pubDate: itemData.date, }; - ctx.cache.set(itemUrl, JSON.stringify(item), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(item)); return Promise.resolve(item); }) ); diff --git a/lib/routes/universities/sdu/cmse.js b/lib/routes/universities/sdu/cmse.js index 45bfc29b10..389a3dea8d 100644 --- a/lib/routes/universities/sdu/cmse.js +++ b/lib/routes/universities/sdu/cmse.js @@ -46,7 +46,7 @@ module.exports = async (ctx) => { description: $('#show_content').html(), pubDate: new Date(date), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/sdu/epe.js b/lib/routes/universities/sdu/epe.js index b520468897..e6c55c40d6 100644 --- a/lib/routes/universities/sdu/epe.js +++ b/lib/routes/universities/sdu/epe.js @@ -45,7 +45,7 @@ module.exports = async (ctx) => { description: $('#show_content').html(), pubDate: new Date(date), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/sdu/grad/academic.js b/lib/routes/universities/sdu/grad/academic.js index cb8caaf193..67fc8c64e6 100644 --- a/lib/routes/universities/sdu/grad/academic.js +++ b/lib/routes/universities/sdu/grad/academic.js @@ -39,7 +39,7 @@ module.exports = async (ctx) => { description: $('.newscontent_1').html(), pubDate: new Date(titleGroup[2].slice(8)), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/sdu/mech.js b/lib/routes/universities/sdu/mech.js index e34a25da74..f102694bbd 100644 --- a/lib/routes/universities/sdu/mech.js +++ b/lib/routes/universities/sdu/mech.js @@ -49,7 +49,7 @@ module.exports = async (ctx) => { description: $('#show_content').html(), pubDate: new Date(date), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/sdu/sc.js b/lib/routes/universities/sdu/sc.js index 962cba90c1..51e75c4e3f 100644 --- a/lib/routes/universities/sdu/sc.js +++ b/lib/routes/universities/sdu/sc.js @@ -47,7 +47,7 @@ module.exports = async (ctx) => { description: $('.newscontent-1').html(), pubDate: new Date(dateDict[itemUrl]), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/seu/cse/index.js b/lib/routes/universities/seu/cse/index.js index a1eacfa0d5..561c03ea5b 100644 --- a/lib/routes/universities/seu/cse/index.js +++ b/lib/routes/universities/seu/cse/index.js @@ -61,7 +61,7 @@ module.exports = async (ctx) => { .trim(), pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/seu/radio/academic.js b/lib/routes/universities/seu/radio/academic.js index 1bd3c2ecea..7d95ed197a 100644 --- a/lib/routes/universities/seu/radio/academic.js +++ b/lib/routes/universities/seu/radio/academic.js @@ -45,7 +45,7 @@ module.exports = async (ctx) => { description: $('.rich_media_content').text(), pubDate: new Date(info.date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); } const single = { @@ -64,7 +64,7 @@ module.exports = async (ctx) => { .replace('发布时间:', '') ).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/shanghaitech/sist/activity.js b/lib/routes/universities/shanghaitech/sist/activity.js index 6c46620d33..8c575c95c4 100644 --- a/lib/routes/universities/shanghaitech/sist/activity.js +++ b/lib/routes/universities/shanghaitech/sist/activity.js @@ -46,7 +46,7 @@ module.exports = async (ctx) => { .trim(), pubDate: new Date(item.date), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/shu/jwc.js b/lib/routes/universities/shu/jwc.js index 80dec9e5f3..34d6b2b615 100644 --- a/lib/routes/universities/shu/jwc.js +++ b/lib/routes/universities/shu/jwc.js @@ -64,7 +64,7 @@ module.exports = async (ctx) => { ).toUTCString(), description: item.title, }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/sjtu/gs/utils.js b/lib/routes/universities/sjtu/gs/utils.js index c31c2a9ebf..600456a5db 100644 --- a/lib/routes/universities/sjtu/gs/utils.js +++ b/lib/routes/universities/sjtu/gs/utils.js @@ -53,7 +53,7 @@ const ProcessFeed = async (list, caches, host) => { const timeZone = 8; const serverOffset = date.getTimezoneOffset() / 60; result[i].pubDate = new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString(); - caches.set(result[i].link, JSON.stringify(result[i]), 1 * 60 * 60); + caches.set(result[i].link, JSON.stringify(result[i])); } return result; diff --git a/lib/routes/universities/sjtu/seiee/utils.js b/lib/routes/universities/sjtu/seiee/utils.js index 62fabf8ab5..fd8591f41a 100644 --- a/lib/routes/universities/sjtu/seiee/utils.js +++ b/lib/routes/universities/sjtu/seiee/utils.js @@ -31,7 +31,7 @@ module.exports = function(meta, extract) { description: $('.article_content').text(), pubDate: new Date(item.date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/universities/swust/cs.js b/lib/routes/universities/swust/cs.js index 11aa3e37a0..0345d1a50d 100644 --- a/lib/routes/universities/swust/cs.js +++ b/lib/routes/universities/swust/cs.js @@ -66,7 +66,7 @@ module.exports = async (ctx) => { link: link, }; - ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(resultItem)); } // }; return Promise.resolve(resultItem); diff --git a/lib/routes/universities/swust/jwc_news.js b/lib/routes/universities/swust/jwc_news.js index d84ca31790..6bb46c113a 100644 --- a/lib/routes/universities/swust/jwc_news.js +++ b/lib/routes/universities/swust/jwc_news.js @@ -37,7 +37,7 @@ module.exports = async (ctx) => { author: author, }; - ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(resultItem)); } return Promise.resolve(resultItem); diff --git a/lib/routes/universities/swust/jwc_notice.js b/lib/routes/universities/swust/jwc_notice.js index 1b2ad95b11..421efb4abe 100644 --- a/lib/routes/universities/swust/jwc_notice.js +++ b/lib/routes/universities/swust/jwc_notice.js @@ -43,7 +43,7 @@ module.exports = async (ctx) => { author: author, }; - ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(resultItem)); } return Promise.resolve(resultItem); diff --git a/lib/routes/universities/szu/yz/utils.js b/lib/routes/universities/szu/yz/utils.js index 414b58f1de..1cb9a78382 100644 --- a/lib/routes/universities/szu/yz/utils.js +++ b/lib/routes/universities/szu/yz/utils.js @@ -77,7 +77,7 @@ const ProcessFeed = async (list, cache, current) => guid: $url, // 文章唯一标识 }; // 将内容写入缓存 - cache.set(key, JSON.stringify(single), 24 * 60 * 60); // 缓存时间为24h + cache.set(key, JSON.stringify(single)); // 缓存时间为24h // 返回列表上提取到的信息 return single; } diff --git a/lib/routes/vgtime/news.js b/lib/routes/vgtime/news.js index e277c48fc4..a161ed0424 100644 --- a/lib/routes/vgtime/news.js +++ b/lib/routes/vgtime/news.js @@ -36,7 +36,7 @@ module.exports = async (ctx) => { $('.editor_name').remove(); const content = $('.vg_main article').html(); // 存放到缓存区 - ctx.cache.set(cacheKey, content, 24 * 60 * 60); + ctx.cache.set(cacheKey, content); news.description = content; } diff --git a/lib/routes/whalegogo/home.js b/lib/routes/whalegogo/home.js index 1cc44bf0f5..282d23041e 100644 --- a/lib/routes/whalegogo/home.js +++ b/lib/routes/whalegogo/home.js @@ -30,7 +30,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date * 1000).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/who/news-room.js b/lib/routes/who/news-room.js index 0db8ea4fe1..c90e1a808a 100644 --- a/lib/routes/who/news-room.js +++ b/lib/routes/who/news-room.js @@ -40,7 +40,7 @@ module.exports = async (ctx) => { item.description = $('article') .html() .replace(/src="\//g, `src="${host}`); - ctx.cache.set(key, item.description, 12 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); diff --git a/lib/routes/woshipm/bookmarks.js b/lib/routes/woshipm/bookmarks.js index 1a4ce10189..714b8e7f20 100644 --- a/lib/routes/woshipm/bookmarks.js +++ b/lib/routes/woshipm/bookmarks.js @@ -34,7 +34,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/woshipm/popular.js b/lib/routes/woshipm/popular.js index b15521d7d1..b225a1751b 100644 --- a/lib/routes/woshipm/popular.js +++ b/lib/routes/woshipm/popular.js @@ -28,7 +28,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(temp.data); single.description = $('.grap').html(); - ctx.cache.set(key, single.description, 60 * 60); + ctx.cache.set(key, single.description); } return Promise.resolve(single); diff --git a/lib/routes/woshipm/user_article.js b/lib/routes/woshipm/user_article.js index f60acae4ff..9f6853441c 100644 --- a/lib/routes/woshipm/user_article.js +++ b/lib/routes/woshipm/user_article.js @@ -50,7 +50,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/xiaoheihe/news.js b/lib/routes/xiaoheihe/news.js index f59798fba9..7629b751e1 100644 --- a/lib/routes/xiaoheihe/news.js +++ b/lib/routes/xiaoheihe/news.js @@ -34,7 +34,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(article.data); const content = $('.article-content').html(); // 存放到缓存区 - ctx.cache.set(cacheKey, content, 24 * 60 * 60); + ctx.cache.set(cacheKey, content); news.description = content; } diff --git a/lib/routes/xueqiu/fund.js b/lib/routes/xueqiu/fund.js index 14e45e853e..249381f3a5 100644 --- a/lib/routes/xueqiu/fund.js +++ b/lib/routes/xueqiu/fund.js @@ -66,6 +66,6 @@ module.exports = async (ctx) => { item: [single], }; - ctx.cache.set(guid, JSON.stringify(ctx.state.data), 2 * 60 * 60); + ctx.cache.set(guid, JSON.stringify(ctx.state.data)); } }; diff --git a/lib/routes/zaker/source.js b/lib/routes/zaker/source.js index 6d3be58f24..21aa11f69c 100644 --- a/lib/routes/zaker/source.js +++ b/lib/routes/zaker/source.js @@ -56,7 +56,7 @@ module.exports = async (ctx) => { description: description, pubDate: date_util(date, 8), }; - ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); }) ); diff --git a/lib/routes/zaobao/realtime.js b/lib/routes/zaobao/realtime.js index b7ca8ca0a1..24b1bc0682 100644 --- a/lib/routes/zaobao/realtime.js +++ b/lib/routes/zaobao/realtime.js @@ -73,7 +73,7 @@ module.exports = async (ctx) => { link: link, }; - ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(resultItem)); } // }; return Promise.resolve(resultItem); diff --git a/lib/routes/zaobao/znews.js b/lib/routes/zaobao/znews.js index 95046deb25..b31e0b23b0 100644 --- a/lib/routes/zaobao/znews.js +++ b/lib/routes/zaobao/znews.js @@ -65,7 +65,7 @@ module.exports = async (ctx) => { link: link, }; - ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60); + ctx.cache.set(link, JSON.stringify(resultItem)); } return Promise.resolve(resultItem); diff --git a/lib/routes/zhihu/daily.js b/lib/routes/zhihu/daily.js index 06428094a9..3e7c2ea0cb 100644 --- a/lib/routes/zhihu/daily.js +++ b/lib/routes/zhihu/daily.js @@ -37,7 +37,7 @@ module.exports = async (ctx) => { }, }); item.description = utils.ProcessImage(storyDetail.data.body.replace(/
([\s\S]*?)<\/div>/g, '$1').replace(/<\/?h2.*?>/g, '')); - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item); diff --git a/lib/routes/zhihu/zhuanlan.js b/lib/routes/zhihu/zhuanlan.js index 57a1341ca1..8ab6c29642 100644 --- a/lib/routes/zhihu/zhuanlan.js +++ b/lib/routes/zhihu/zhuanlan.js @@ -69,7 +69,7 @@ module.exports = async (ctx) => { ); } - ctx.cache.set(key, item.description, 24 * 60 * 60); + ctx.cache.set(key, item.description); } return Promise.resolve(item);