From b156be8007ba4ea0c226f99f1903dbce7444ee14 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sun, 28 Oct 2018 02:24:42 +0800 Subject: [PATCH] fix instagram cache #963 --- routes/instagram/user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/instagram/user.js b/routes/instagram/user.js index 67899dcd3..9f6cbd5c2 100644 --- a/routes/instagram/user.js +++ b/routes/instagram/user.js @@ -24,7 +24,7 @@ module.exports = async (ctx) => { item = item.node; const url = `https://www.instagram.com/p/${item.shortcode}`; - const cache = await ctx.cache.get(item.shortcode); + const cache = await ctx.cache.get(url); if (cache) { return Promise.resolve(JSON.parse(cache)); } @@ -34,7 +34,7 @@ module.exports = async (ctx) => { image: item.display_url, }; - ctx.cache.set(item.shortcode, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60); 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(item.shortcode, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify(single), 24 * 60 * 60); 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(item.shortcode, JSON.stringify(single), 24 * 60 * 60); + ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60); return Promise.resolve([single]); } })