@neutrium/utilities - v5.0.0
    Preparing search index...

    Class LruCache<K, V>

    Synchronous, bounded cache using Map key identity (SameValueZero). Successful get/set refresh recency; has/peek/keys do not. Values are not copied. Rejected or throwing insertions leave the cache unchanged. Callbacks must not mutate this cache. No TTL, background work, or asynchronous loading is performed.

    Type Parameters

    • K
    • V

    Hierarchy (View Summary)

    Index
    • Remove an entry and its weight; return whether it existed.

      Parameters

      • key: K

      Returns boolean

    • Read a value and mark an existing entry most recently used.

      Parameters

      • key: K

      Returns V | undefined

    • Read and refresh an existing entry, including undefined, or synchronously create it. The factory receives the key and runs only on a miss, even when retention is disabled. Return the computed value whether or not it is admitted. Factory and insertion errors propagate; the factory must not mutate this cache. Promise values are stored as-is.

      Parameters

      • key: K
      • factory: (key: K) => V

      Returns V

    • Test membership without refreshing recency.

      Parameters

      • key: K

      Returns boolean

    • Live iterator, ordered least to most recently used.

      Returns MapIterator<K>

    • Read a value without refreshing recency; missing keys return undefined.

      Parameters

      • key: K

      Returns V | undefined

    • Chainable insertion. Use trySet when admission needs to be observed.

      Parameters

      • key: K
      • value: V

      Returns this

    • False means disabled or oversized. An existing value is preserved on rejection.

      Parameters

      • key: K
      • value: V

      Returns boolean