Retrieves an entry.
The key of the entry to be retrieved
A promise resolving to the entry stored under key, or to undefined if the store holds none
Inserts an entry.
The key the entry is to be stored under
The entry to be stored
A promise resolving when entry is stored
Removes an entry.
States an outcome rather than a change: removing a key the store doesn't hold succeeds without doing anything, so a caller is free to remove a key without first checking for it.
The key of the entry to be removed
A promise resolving when no entry is stored under key
Backing store for cached responses.
Holds the responses a cache middleware is to answer from, so that entries live wherever the consumer needs them, whether in memory, on the file system or in a shared key-value service. A store keeps a private cache, so the entries it holds are to serve one user alone, however widely the service backing it is reached. Keys are opaque strings, computed by the middleware from the target URI of the request and from the header fields the response states as varying. The fragment plays no part, as it never reaches the origin server, so requests differing by fragment alone share one entry and invalidate it together.
Retention is the store's own concern. Beyond the default memory store, which gives up the least recently used entries once its limit is reached, no implementation is provided: how many entries a store holds, and which it gives up first, are the consumer's to decide.