Fix LRUCache eviction

This commit is contained in:
Jon Staab
2023-12-11 12:04:55 -08:00
parent bdaf42f213
commit 1e2d806d25
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -12,7 +12,11 @@ export class LRUCache<T, U> {
const v = this.map.get(k)
if (v !== undefined) {
this.keys.push(this.keys.shift() as T)
this.keys.push(k as T)
if (this.keys.length > this.maxSize) {
this.keys.splice(-this.maxSize)
}
}
return v