Skip to content

Commit a820479

Browse files
committed
🐛 Fix to avoid counting existing entry twice (#1995)
1 parent 6d484dd commit a820479

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lib/clients/cache.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export class Cache<T> {
7070
throw new Error('Invalid cache key');
7171
}
7272

73+
// Note: Remove existing entry first to avoid counting it twice.
74+
this.cache.delete(key);
75+
7376
if (this.cache.size >= this.maxSize) {
7477
const oldestKey = this.findOldestEntry();
7578

0 commit comments

Comments
 (0)