Get cached data and refresh the inactivity timer
(url: string)
| 724 | |
| 725 | /** Get cached data and refresh the inactivity timer */ |
| 726 | function getCacheEntry(url: string): Uint8Array | undefined { |
| 727 | const entry = cache.get(url); |
| 728 | if (!entry) return undefined; |
| 729 | |
| 730 | // Refresh inactivity timer on access |
| 731 | clearTimeout(entry.inactivityTimer); |
| 732 | entry.inactivityTimer = setTimeout(() => { |
| 733 | deleteCacheEntry(url); |
| 734 | }, CACHE_INACTIVITY_TIMEOUT_MS); |
| 735 | |
| 736 | // Move to end of insertion order so size-cap eviction is LRU. |
| 737 | cache.delete(url); |
| 738 | cache.set(url, entry); |
| 739 | |
| 740 | return entry.data; |
| 741 | } |
| 742 | |
| 743 | /** Add data to cache with both inactivity and max lifetime timers */ |
| 744 | function setCacheEntry(url: string, data: Uint8Array): void { |
no test coverage detected
searching dependent graphs…