Skip to content

Interface: CacherOptions ​

The options of a Cacher component, given to buildCacherOptions (or next to class: Cacher in the components of an application). They are validated when the component is created.

Properties ​

cacheId? ​

optional cacheId?: string

An identifier of the cache. It is accepted for compatibility and not used.


nonBlocking? ​

optional nonBlocking?: boolean

Whether the writes and the deletions return without waiting for the stores (their failures emitted as events, the calls never rejecting), and, with several stores, the reads query them all at once and return the first entry found (not necessarily the first store's).

Default ​

ts
false

refreshAllStores? ​

optional refreshAllStores?: boolean

Whether a background refresh of wrap() writes the new value to all the stores, instead of the store holding the value and the stores above it.

Default ​

ts
false

refreshThreshold? ​

optional refreshThreshold?: number

The default refresh threshold of wrap(), in milliseconds (a positive integer): a cached value with less time to live is returned and recomputed in the background.

Default ​

ts
none: no background refresh

stores? ​

optional stores?: CacheStoreOptions | CacheStoreOptions[]

The stores, the fastest first: the options of one store or an array of them, type choosing the store ('memory', 'file', 'redis', 'memcache', 'mongo', 'sqlite', 'postgres', 'mysql'). A read returns the entry of the first store holding it; a write or a deletion goes to all of them.

Default ​

ts
one in-memory store

ttl? ​

optional ttl?: number

The default time to live of the entries, in milliseconds (a positive integer), used when a write gives none.

Default ​

ts
none: the entries never expire

Released under the MIT License.