PersistentCache class
A simple persistent key-value store. Used to implement Limits.cache for throttle().
Signature:
export declare class PersistentCache
Remarks
Entries can be expired, but are not actually deleted individually. The entire cache can be deleted at once. Hence this cache is useful for storing results that are expensive to compute but do not change too often (e.g. the node_modules folder from an 'npm install' where 'package.json' is not expected to change too often).
By default faast.js will use the directory ~/.faastjs
as a local cache to store data such as pricing retrieved from cloud APIs, and garbage collection information. This directory can be safely deleted if no faast.js instances are running.
Constructors
Constructor |
Modifiers |
Description |
---|---|---|
Construct a new persistent cache, typically used with Limits as part of the arguments to throttle(). |
Properties
Property |
Modifiers |
Type |
Description |
---|---|---|---|
|
string |
The directory on disk where cached values are stored. | |
|
string |
The directory under the user's home directory that will be used to store cached values. The directory will be created if it doesn't exist. | |
|
number |
The age (in ms) after which a cached entry is invalid. Default: |
Methods
Method |
Modifiers |
Description |
---|---|---|
Deletes all cached entries from disk. | ||
Retrieve all keys stored in the cache, including expired entries. | ||
Retrieves the value previously set for the given key, or undefined if the key is not found. | ||
Set the cache key to the given value. |