MCPcopy Create free account
hub / github.com/modelcontextprotocol/ext-apps / getCacheEntry

Function getCacheEntry

examples/pdf-server/server.ts:726–741  ·  view source on GitHub ↗

Get cached data and refresh the inactivity timer

(url: string)

Source from the content-addressed store, hash-verified

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 {

Callers 1

readPdfRangeFunction · 0.85

Calls 1

deleteCacheEntryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…