Type Alias Options<KeyType, ValueType>

Options: {
    maxAge?: number;
    maxSize: number;
    onEviction?: (key: KeyType, value: ValueType) => void;
}

Type Parameters

  • KeyType
  • ValueType

Type declaration

  • Optional ReadonlymaxAge?: number

    The maximum number of milliseconds an item should remain in the cache.

    Infinity

    By default, maxAge will be Infinity, which means that items will never expire. Lazy expiration upon the next write or read call.

    Individual expiration of an item can be specified by the set(key, value, maxAge) method.

  • ReadonlymaxSize: number

    The maximum number of items before evicting the least recently used items.

  • OptionalonEviction?: (key: KeyType, value: ValueType) => void

    Called right before an item is evicted from the cache.

    Useful for side effects or for items like object URLs that need explicit cleanup (revokeObjectURL).