Skip to content
Snippets Groups Projects
Commit 26f23eb5 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

feat: expire changelog cache after 1 hour

parent f8a9ebf9
No related branches found
No related tags found
No related merge requests found
...@@ -22,19 +22,18 @@ async function getChangeLogJSON(args) { ...@@ -22,19 +22,18 @@ async function getChangeLogJSON(args) {
const cacheVal = await cacache.get(...cache); const cacheVal = await cacache.get(...cache);
logger.trace(`Returning cached version of ${depName}`); logger.trace(`Returning cached version of ${depName}`);
const cachedResult = JSON.parse(cacheVal.data.toString()); const cachedResult = JSON.parse(cacheVal.data.toString());
if (cachedResult) { if (
if (DateTime.local() < DateTime.fromISO(cachedResult.expiry)) { cachedResult &&
logger.debug('Cache hit'); DateTime.local() < DateTime.fromISO(cachedResult.expiry)
delete cachedResult.expiry; ) {
return cachedResult; logger.debug('Cache hit');
} delete cachedResult.expiry;
logger.debug('Cache expiry'); return cachedResult;
} }
return null;
} catch (err) { } catch (err) {
logger.debug('Cache miss'); logger.debug('Cache miss');
return null;
} }
return null;
} }
async function setChangeLogJSON(args, res) { async function setChangeLogJSON(args, res) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment