Type Alias Options<KeyType, ValueType>
type Options<KeyType, ValueType> = {
maxAge?: number;
maxSize: number;
onEviction?: (key: KeyType, value: ValueType) => void;
}
maxAge?: number;
maxSize: number;
onEviction?: (key: KeyType, value: ValueType) => void;
}
Type Parameters
- KeyType
- ValueType
Properties
Optional ReadonlymaxAge
maxAge?: number
ReadonlymaxSize
maxSize: number
The target maximum number of items before evicting the least recently used items.
Note: This package uses an algorithm which maintains between maxSize and 2 × maxSize items for performance reasons. The cache may temporarily contain up to twice the specified size due to the dual-cache design that avoids expensive delete operations.
OptionalonEviction
Called right before an item is evicted from the cache due to LRU pressure, TTL expiration, or manual eviction via evict().
Useful for side effects or for items like object URLs that need explicit cleanup (revokeObjectURL).
Note: This callback is not called for manual removals via delete() or clear(). It fires for automatic evictions and manual evictions via evict().
The maximum number of milliseconds an item should remain in the cache.