Fix LRUCache eviction
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paravel",
|
||||
"version": "0.4.13",
|
||||
"version": "0.4.14",
|
||||
"description": "Yet another toolkit for nostr",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user