()
| 66 | } |
| 67 | |
| 68 | private evict(): void { |
| 69 | // LRU eviction: remove least recently used (lowest hits) |
| 70 | let minHits = Infinity; |
| 71 | let evictKey: string | null = null; |
| 72 | |
| 73 | for (const [key, entry] of this.cache.entries()) { |
| 74 | if (entry.hits < minHits) { |
| 75 | minHits = entry.hits; |
| 76 | evictKey = key; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if (evictKey) { |
| 81 | this.cache.delete(evictKey); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | getStats() { |
| 86 | return { |