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

    Class WeightedLruCache<K, V>

    LRU bounded by both entry count and caller-defined weight units.

    Type Parameters

    • K
    • V

    Hierarchy (View Summary)

    Index
    • get size(): number

      Number of currently retained entries.

      Returns number

    • get weight(): number

      Sum of currently retained entry weights.

      Returns number

    • 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

    • 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