From 196220868df0d76d638414b1ad80496a43f90fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=95=BF=E5=AE=89?= Date: Thu, 31 Jan 2019 11:46:05 +0800 Subject: [PATCH] :bug: Fix #1499 (#1503) --- lib/routes/d2/daily.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/routes/d2/daily.js b/lib/routes/d2/daily.js index 35b3a21b3d..93dc8d18b1 100644 --- a/lib/routes/d2/daily.js +++ b/lib/routes/d2/daily.js @@ -18,7 +18,7 @@ module.exports = async (ctx) => { const relativePath = ele.attr('href'); const innerText = ele.text(); const link = url.resolve(indexLink, relativePath); - const cache = ctx.cache.get(link); + const cache = await ctx.cache.get(link); if (cache) { return cache; } @@ -32,13 +32,15 @@ module.exports = async (ctx) => { description = sanitizeHtml(description, { allowedTags: ['section', 'h2', 'ul', 'li', 'p', 'span', 'a'], }); - return { + const item = { title: $('head>title').text(), pubDate: new Date(innerText.trim()).toUTCString(), description, guid: link, link, }; + await ctx.cache.set(link, cache, 24 * 60 * 60); + return item; }); ctx.state.data = {