Class: ClientRequestCache

ClientRequestCache(ttl, size, requestFunc)

Caches requests in memory and handles expiring them.

Constructor

new ClientRequestCache(ttl, size, requestFunc)

Parameters:
Name Type Description
ttl Number How old a result can be before it gets expired.
size Number How many results to store before we trim.
requestFunc The function to use on cache miss.
Source:

Methods

get(}, …args) → {Promise}

Gets a result of a request from the cache, or otherwise tries to fetch the the result with this.requestFunc
Parameters:
Name Type Attributes Description
} string key Key of the item to get/store.
args Array.<any> <repeatable>
A set of arguments to pass to the request func.
Source:
Throws:
If the key is not a string.
Type
Error
Returns:
The request, or undefined if not retrievable.
Type
Promise

getCachedResults() → {Map.<string, any>}

Clone the current request result cache, mapping keys to their cache records.
Source:
Returns:
Type
Map.<string, any>