| 673 | } |
| 674 | |
| 675 | get(cacheKey: string) { |
| 676 | const val = this.#cacheKeyToEntryMap.get(cacheKey); |
| 677 | |
| 678 | if (val && !val.validate()) { |
| 679 | this.delete(cacheKey); |
| 680 | this.#statsCounter.recordEvictions(1); |
| 681 | // Entry failed validation - this is TTL expiry since invalidation marks are handled separately |
| 682 | publish(CHANNELS.CACHE_EVICTION, () => ({ reason: 'ttl', count: 1 })); |
| 683 | this.emit("cache-evict", cacheKey); |
| 684 | |
| 685 | return undefined; |
| 686 | } |
| 687 | |
| 688 | if (val !== undefined && this.lru) { |
| 689 | this.#cacheKeyToEntryMap.delete(cacheKey); |
| 690 | this.#cacheKeyToEntryMap.set(cacheKey, val); |
| 691 | } |
| 692 | |
| 693 | return val; |
| 694 | } |
| 695 | |
| 696 | delete(cacheKey: string) { |
| 697 | const entry = this.#cacheKeyToEntryMap.get(cacheKey); |