Skip to content

LRUCache

Defined in: packages/core/src/lru-cache.ts:5

Simple LRU cache with bounded size using Map insertion order. Evicts the least-recently-used entry when the cache is full.

K

V

new LRUCache<K, V>(maxSize?): LRUCache<K, V>

Defined in: packages/core/src/lru-cache.ts:12

number = 1000

LRUCache<K, V>

get size(): number

Defined in: packages/core/src/lru-cache.ts:125

number

get(key): V | undefined

Defined in: packages/core/src/lru-cache.ts:19

K

V | undefined


has(key): boolean

Defined in: packages/core/src/lru-cache.ts:116

K

boolean


prepareSet(key, value): () => void

Defined in: packages/core/src/lru-cache.ts:58

Internal

Stage a single-entry insertion; see prepareSetMany(). The returned finalizer is the only strong owner of the unfinalized entry, which is never visible to get, has, or size. The cache keeps a weak reference solely so a same-key write before finalization supersedes the staged value. Only the finalizer assigns _finalizedEntries; ordinary cache operations materialize the committed entry into the backing Map afterward. The finalizer is idempotent and performs no Map work. Callers must not finalize competing prepared insertions. Used within an externally reserved commit boundary.

K

V

() => void


prepareSetMany(entries): () => void

Defined in: packages/core/src/lru-cache.ts:77

Internal

Flush any previously finalized overlay, then stage a bounded batch insertion. All Map work happens before this method returns; the returned finalizer only exposes the prebuilt overlay. Until finalization, that finalizer is the only strong owner of the staged entries: the cache holds them through a weak reference and never exposes them to get, has, or size, so dropping an abandoned finalizer releases the staged values. Cache activity before finalization is retained when the overlay is later materialized; a write to a staged key before finalization supersedes the staged value. Callers must reserve the cache from claim through finalization and must not compose competing prepared insertions. Finalization cannot check or throw after another provider may already have committed; validate before obtaining it. Used within an externally reserved commit boundary.

ReadonlyMap<K, V>

() => void


set(key, value): void

Defined in: packages/core/src/lru-cache.ts:41

K

V

void