@adviser/cement - v0.0.0
    Preparing search index...

    Class LRUMap<K, V>

    A Map implementation with Least Recently Used (LRU) eviction policy.

    LRUMap maintains key-value pairs with automatic eviction of least recently accessed items when capacity limits are reached. Provides configurable eviction and refresh strategies, event callbacks, and access statistics.

    const cache = new LRUMap<string, number>({ maxEntries: 100 });

    // Add items
    cache.set('key1', 42);
    cache.set('key2', 100);

    // Get items (updates access order)
    const value = cache.get('key1');

    // Listen for evictions
    const unregister = cache.onDelete((key, value) => {
    console.log(`Evicted: ${key} = ${value}`);
    });

    Type Parameters

    • K

      The type of keys in the map

    • V

      The type of values in the map

    Index

    Constructors

    Properties

    _map: Map<K, LRUItem<V>> = ...
    param: MutableLRUParam<V, K>
    stats: { gets: number; puts: number; deletes: number } = ...
    _onSetFns: Map<string, LRUMapFn<V, K>> = ...
    _onDeleteFns: Map<string, LRUMapFn<V, K>> = ...

    Accessors

    Methods

    • Parameters

      • key: K
      • createFN: (key: K) => Promise<V>

      Returns Promise<V | undefined>