diff --git a/lib/routes/unit-image/films.js b/lib/routes/unit-image/films.js index bdb51e40f..a3adb57ec 100755 --- a/lib/routes/unit-image/films.js +++ b/lib/routes/unit-image/films.js @@ -12,7 +12,10 @@ module.exports = async (ctx) => { const articledata = await Promise.all( list.map(async (item) => { const url = `https://www.unit-image.fr/data/en/wp-json/unitimage/v1${item.href}`; // 获取所有文章URL - + const cache = await ctx.cache.get(url); // 这里是不是单单缓存 URL? + if (cache) { + return Promise.resolve(JSON.parse(cache)); // 如果有 URL 的缓存,则返回 JSON.phrase 的数据 + } const response2 = await got({ method: 'get', url, @@ -63,6 +66,7 @@ module.exports = async (ctx) => { compare, bhts, }; + ctx.cache.set(url, JSON.stringify(single)); // 设定缓存为序列化文章数据 return Promise.resolve(single); // 返回 articledata 为序列化文章数据。 }) );