cache
ts
import { cache } from 'feathers-utils/hooks';Type declaration
ts
type Cache = {
get: (key: string) => Promisable<any>
set: (key: string, value: any) => Promisable<any>
delete: (key: string) => Promisable<any>
clear: () => any
keys: () => Generator<string, void, unknown>
}
export type CacheOptions = {
/**
* The cache implementation to use. It should implement the methods `get`, `set`, `delete`, `clear`, and `keys`.
* This can be a Map, Redis client, or any other cache implementation.
*
* Use 'lru-cache' for an LRU cache implementation.
*/
map: Cache
/**
* The id field to use for caching. Defaults to `service.options.id` and if not found, then 'id'.
*/
id?: string
/**
* params are stringified for the key-value cache.
* There are params properties you don't want to include in the cache key.
* You can use this function to transform the params before they are stringified.
*/
transformParams: (params: Params) => Params
}
export declare const cache: <H extends HookContext = HookContext>(
options: CacheOptions,
) => (context: H, next?: NextFunction) => Promise<HookContext>| Argument | Type | Description |
|---|---|---|
| options | CacheOptions |
| type | methods | multi |
|---|---|---|
| before, after | find, get, create, update, patch, remove | yes |
