Amazon Vinyl
    Preparing search index...

    Interface CacheMap<K, V>

    A map that notifies when an entry is evicted.

    Mirrors the ES2015 Map<K, V> interface (no iteration methods) so implementers are not coupled to the evolving MapIterator shape in newer lib types.

    interface CacheMap<K, V> {
        onEvict: ((element: V, key: K, list: CacheMap<K, V>) => void) | null;
        size: number;
        clear(): void;
        delete(key: K): boolean;
        forEach(
            callbackfn: (value: V, key: K, map: CacheMap<K, V>) => void,
            thisArg?: any,
        ): void;
        get(key: K): V | undefined;
        has(key: K): boolean;
        set(key: K, value: V): this;
    }

    Type Parameters

    • K
    • V

    Implemented by

    Index
    onEvict: ((element: V, key: K, list: CacheMap<K, V>) => void) | null

    When an entry is added when at capacity, the least recently used entry will be removed. This callback can be set to be notified with the element and key being evicted, which may be used for disposal.

    size: number