Sweep caches on the ttl interval

This commit is contained in:
Cadence Fish 2020-03-01 16:49:16 +13:00
parent bf3145b684
commit 51e85e6bb9
No known key found for this signature in database
GPG Key ID: 81015DF9AA8607E1
1 changed files with 3 additions and 0 deletions

View File

@ -9,6 +9,9 @@ class TtlCache {
this.ttl = ttl
/** @type {Map<string, {data: T, time: number}>} */
this.cache = new Map()
this.sweepInterval = setInterval(() => {
this.clean()
}, this.ttl)
}
clean() {