CacheStore

Interface defining a cache store. Implement this interface to create a custom cache store.


interface CacheStore {
  set<T>(key: string, value: T, options?: number | CacheStoreSetOptions<T>): Promise<void> | void
  get<T>(key: string): Promise<T | undefined> | T | undefined
  del(key: string)?: void | Promise<void>
}

Methods

set()

Create a key/value pair in the cache.


set<T>(key: string, value: T, options?: number | CacheStoreSetOptions<T>): Promise<void> | void

Parameters

Option Type Description
key string

cache key

value T

cache value

options number | CacheStoreSetOptions

Optional. Default is undefined.

Returns

Promise<void> | void

get()

Retrieve a key/value pair from the cache.


get<T>(key: string): Promise<T | undefined> | T | undefined

Parameters

Option Type Description
key string

cache key

Returns

Promise<T | undefined> | T | undefined

del()

Destroy a key/value pair from the cache.


del(key: string)?: void | Promise<void>

Parameters

Option Type Description
key string

cache key

Returns

void | Promise<void>