Documentation / @andrew_l/toolkit / withCacheLRU
Function: withCacheLRU() ​
withCacheLRU<
T>(__namedParameters,fn):WithCacheResult<T>
Wrap a function to cache results by arguments
But with LRU
Type Parameters ​
T ​
T extends AnyFunction
Parameters ​
__namedParameters ​
fn ​
T
Returns ​
Example ​
ts
const sum = withCacheLRU({ capacity: 100 }, (a, b) => {
console.log('calc?');
return a + b;
});
sum(1, 2); // calc?
sum(1, 2);