From 26f23eb50eac3bdbfc849e4d2cb905ef6250ff52 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 14 Jun 2018 09:48:00 +0200 Subject: [PATCH] feat: expire changelog cache after 1 hour --- lib/workers/pr/changelog/source-cache.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/workers/pr/changelog/source-cache.js b/lib/workers/pr/changelog/source-cache.js index d850c9dce6..46e3c93e36 100644 --- a/lib/workers/pr/changelog/source-cache.js +++ b/lib/workers/pr/changelog/source-cache.js @@ -22,19 +22,18 @@ async function getChangeLogJSON(args) { const cacheVal = await cacache.get(...cache); logger.trace(`Returning cached version of ${depName}`); const cachedResult = JSON.parse(cacheVal.data.toString()); - if (cachedResult) { - if (DateTime.local() < DateTime.fromISO(cachedResult.expiry)) { - logger.debug('Cache hit'); - delete cachedResult.expiry; - return cachedResult; - } - logger.debug('Cache expiry'); + if ( + cachedResult && + DateTime.local() < DateTime.fromISO(cachedResult.expiry) + ) { + logger.debug('Cache hit'); + delete cachedResult.expiry; + return cachedResult; } - return null; } catch (err) { logger.debug('Cache miss'); - return null; } + return null; } async function setChangeLogJSON(args, res) { -- GitLab