MCPcopy Create free account
hub / github.com/Effect-TS/effect / checkCapacity

Function checkCapacity

packages/effect/src/Cache.ts:491–500  ·  view source on GitHub ↗
(self: Cache<K, A, E, R>)

Source from the content-addressed store, hash-verified

489}
490
491const checkCapacity = <K, A, E, R>(self: Cache<K, A, E, R>) => {
492 let diff = MutableHashMap.size(self.map) - self.capacity
493 if (diff <= 0) return
494 // MutableHashMap has insertion order, so we can remove the oldest entries
495 for (const [key] of self.map) {
496 MutableHashMap.remove(self.map, key)
497 diff--
498 if (diff === 0) return
499 }
500}
501
502/**
503 * Reads an existing cache entry without invoking the lookup function.

Callers 1

Cache.tsFile · 0.70

Calls 2

sizeMethod · 0.65
removeMethod · 0.45

Tested by

no test coverage detected