new promises.Memoize(maxCacheSize, fn)
An object that has the ability to memoize promises returned by a given user-defined function.
Parameters:
Name | Type | Description |
---|---|---|
maxCacheSize |
number | the maximum number of distinct calls to cache. |
fn |
function | a user-defined function that returns a promise. |
- Source:
Methods
hitRate() → {number}
Return the cache hit rate.
- Source:
Returns:
the hit rate.
- Type
- number
hits() → {number}
Return the number of cache hits.
- Source:
Returns:
the number of hits.
- Type
- number
misses() → {number}
Return the number of cache misses.
- Source:
Returns:
the number of misses.
- Type
- number
missRate() → {number}
Return the cache miss rate.
- Source:
Returns:
the miss rate.
- Type
- number
promise(…args) → {Promise}
Either read the cache or call the user-defined function and get a new promise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
* |
<repeatable> |
a list of arguments to pass to the user-defined function. |
- Source:
Returns:
a promise to be resolved at a later stage.
- Type
- Promise