From 9a416a643b8ca8fcbcbb4269c6ebe8169dd31707 Mon Sep 17 00:00:00 2001 From: Cadence Fish Date: Wed, 18 Mar 2020 21:14:12 +1300 Subject: [PATCH] Sweep caches more frequently --- src/lib/cache.js | 4 +++- src/lib/constants.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/cache.js b/src/lib/cache.js index 107fc00..2e8a9a9 100644 --- a/src/lib/cache.js +++ b/src/lib/cache.js @@ -1,3 +1,5 @@ +const constants = require("./constants") + /** * @template T */ @@ -11,7 +13,7 @@ class TtlCache { this.cache = new Map() this.sweepInterval = setInterval(() => { this.clean() - }, this.ttl) + }, constants.caching.cache_sweep_interval) } clean() { diff --git a/src/lib/constants.js b/src/lib/constants.js index 07fa04d..a540a99 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -38,6 +38,7 @@ let constants = { resource_cache_time: 30*60*1000, instance_list_cache_time: 3*60*1000, updater_cache_time: 2*60*1000, + cache_sweep_interval: 3*60*1000, db_user_id: true, db_post_n3: true },