Create a Promise-returning Function that returns the
memoized results of a Promise. The key for the lookup cache is
determined by the keyExtractor Function.
An optional Map instance can be provided to be used as cache. This
allows for example to prepopulate the cache, or to force recomputation of
some values by removing their corresponding keys. If no instance is provided
an empty Map will be created.
Remarks
If the Promise throws an error, no result will be cached and the
Promise will be run again next time.
Create a Promise-returning Function that returns the memoized results of a Promise. The key for the lookup cache is determined by the
keyExtractorFunction.An optional Map instance can be provided to be used as cache. This allows for example to prepopulate the cache, or to force recomputation of some values by removing their corresponding keys. If no instance is provided an empty Map will be created.
Remarks
If the Promise throws an error, no result will be cached and the Promise will be run again next time.
Example
Memoize the
fetchfunctionExample
Provide an initial cache restored from database
Example
Clear cache after 5 seconds
Returns
the memoized result