mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 08:29:42 +02:00
chore: bump version to 0.1477
Location: Ko Samui Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -199,10 +199,15 @@ export class LRUMap<K, V> extends Map<K, V> {
|
||||
const now = Date.now();
|
||||
const cutoff = now - maxAge;
|
||||
let evicted = 0;
|
||||
let deletedNewest = false;
|
||||
|
||||
// Iterate from oldest to newest
|
||||
for (const [key, value] of super.entries()) {
|
||||
if (getTimestamp(value) < cutoff) {
|
||||
// Track if we're deleting the newest key
|
||||
if (key === this._newestKey) {
|
||||
deletedNewest = true;
|
||||
}
|
||||
super.delete(key);
|
||||
this.onEvict?.(key, value);
|
||||
evicted++;
|
||||
@@ -213,6 +218,14 @@ export class LRUMap<K, V> extends Map<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
// Update _newestKey if we deleted it (find new newest from remaining entries)
|
||||
if (deletedNewest) {
|
||||
this._newestKey = undefined;
|
||||
for (const k of super.keys()) {
|
||||
this._newestKey = k; // Last one becomes newest
|
||||
}
|
||||
}
|
||||
|
||||
return evicted;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user