refactor: fix
This commit is contained in:
1 parent
fc5889b99c
commit
4969ad0ec8
7 files changed
+54
-48
No files matched your search
@@ -30,4 +30,13 @@ export class LRUCache<K, V> {
|
||||
}
|
||||
this.cache.set(key, value);
|
||||
}
|
||||
public resetCapacity(newCapacity: number): void {
|
||||
this.capacity = newCapacity;
|
||||
while (this.cache.size > this.capacity) {
|
||||
const firstKey = this.cache.keys().next().value;
|
||||
if (firstKey !== undefined) {
|
||||
this.cache.delete(firstKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user