MCPcopy Create free account
hub / github.com/modem-dev/hunk / enforceCacheLimit

Function enforceCacheLimit

src/ui/diff/useHighlightedDiff.ts:20–27  ·  view source on GitHub ↗

Evict the oldest entries when the cache exceeds MAX_CACHE_ENTRIES. * Map iteration order is insertion order, so the first keys are the oldest.

()

Source from the content-addressed store, hash-verified

18/** Evict the oldest entries when the cache exceeds MAX_CACHE_ENTRIES.
19 * Map iteration order is insertion order, so the first keys are the oldest. */
20function enforceCacheLimit() {
21 while (SHARED_HIGHLIGHTED_DIFF_CACHE.size > MAX_CACHE_ENTRIES) {
22 const oldest = SHARED_HIGHLIGHTED_DIFF_CACHE.keys().next().value;
23 if (oldest !== undefined) {
24 SHARED_HIGHLIGHTED_DIFF_CACHE.delete(oldest);
25 }
26 }
27}
28
29/** Summarize rendered diff lines without serializing whole arrays into the cache key. */
30function lineSetFingerprint(lines: string[] | undefined) {

Callers 1

commitHighlightResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected