DefaultMemoizeCache Class
Package: @esfx/fn
The default implementation of a MemoizeCache<A, T>, as used by memoize(factory, options).
Non-primitive keys have a lifetime scoped to both the life of the key (using a WeakMap
) and
the life of the cache. Results associated with a non-primitive key can be garbage collected if
the key is garbage collected.
Primitive keys have a lifetime scoped to the life of the cache, so results associated with a primitive key can only be garbage collected if the cache is garbage collected.
Declaration
export declare class DefaultMemoizeCache<A extends unknown[], T> implements MemoizeCache<A, T>
Methods
clear()
Clears the cache.
Declaration
clear(): void;
Returns
void
get(args)
Gets or creates a cache entry for the provided sequence of arguments.
Declaration
get(args: Readonly<A>): MemoizeCacheEntry<T>;
Parameters
- args
- Readonly<A>
Returns
has(args)
Tests whether the cache has a result for the provided sequence of arguments.
Declaration
has(args: Readonly<A>): boolean;
Parameters
- args
- Readonly<A>