From 51e85e6bb9338ba01895d5cb9df9d0d05ef50b58 Mon Sep 17 00:00:00 2001 From: Cadence Fish Date: Sun, 1 Mar 2020 16:49:16 +1300 Subject: [PATCH] Sweep caches on the ttl interval --- src/lib/cache.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/cache.js b/src/lib/cache.js index 5524980..107fc00 100644 --- a/src/lib/cache.js +++ b/src/lib/cache.js @@ -9,6 +9,9 @@ class TtlCache { this.ttl = ttl /** @type {Map} */ this.cache = new Map() + this.sweepInterval = setInterval(() => { + this.clean() + }, this.ttl) } clean() {