OptionalcacheIf true, errors thrown by the function will be cached and re-thrown. If false (default), errors will not be cached and the function will be re-executed on subsequent calls.
OptionalenableEnable cache statistics tracking (hits, misses, evictions).
OptionalkeyCustom function to generate cache keys from function arguments. If not provided, a safe JSON.stringify is used.
OptionalmaxMaximum size in bytes for a single cache entry. Prevents memory bombs. If not provided, no size limit is enforced.
OptionalmaxMaximum number of cache entries. When exceeded, the oldest entry is removed. If not provided, cache size is unlimited.
Eviction uses an approximate LRU strategy for performance. Access order is only
updated when the cache is at or above 90 % of maxSize. Below that threshold, entries
are evicted in insertion order (FIFO), not true least-recently-used order. This is a
deliberate trade-off: avoid paying the cost of a Map re-insert on every cache hit when
the cache still has plenty of headroom.
If your workload has a small working set relative to maxSize and strict LRU ordering
matters, set maxSize closer to the number of distinct argument combinations you expect.
OptionalttlTime in milliseconds after which a cached result expires. If not provided, cached results never expire.
Options for configuring the memoize function.