@neutrium/utilities - v3.1.0
    Preparing search index...

    Interface CachePolicy<V>

    Synchronous admission, size estimation and optional ownership-copy callbacks. Methods may be inherited. Callback references are captured at construction and invoked with the original policy as this; policy state is not copied or frozen.

    interface CachePolicy<V> {
        entryOverheadBytes?: number;
        accept?(key: string, value: V): boolean;
        detach?(value: V): V;
        measure(value: V): number;
    }

    Type Parameters

    • V
    Index
    entryOverheadBytes?: number

    Estimated per-entry overhead; defaults to 256 bytes.

    • Reject before measuring or copying. Must not mutate this cache.

      Parameters

      • key: string
      • value: V

      Returns boolean

    • Optional ownership copy, called only after admission. Its size must match measure.

      Parameters

      • value: V

      Returns V

    • Estimated retained payload bytes, excluding the key and entry overhead.

      Parameters

      • value: V

      Returns number