Fix LRUCache eviction
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "paravel",
|
"name": "paravel",
|
||||||
"version": "0.4.13",
|
"version": "0.4.14",
|
||||||
"description": "Yet another toolkit for nostr",
|
"description": "Yet another toolkit for nostr",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ export class LRUCache<T, U> {
|
|||||||
const v = this.map.get(k)
|
const v = this.map.get(k)
|
||||||
|
|
||||||
if (v !== undefined) {
|
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
|
return v
|
||||||
|
|||||||
Reference in New Issue
Block a user