Abstract Class: CacheProvider
Defined in: CacheProvider.ts:14
Contract every cache provider implements.
delMany and clear are optional in practice: the base class supplies working defaults that behave exactly as the store did before they existed, so a third-party provider written against the older contract keeps working unchanged. Providers backed by a store with batch operations should override them - a purge is otherwise one round trip per key.
See
https://github.com/strapi-community/plugin-rest-cache/issues/131
Constructors
Constructor
new CacheProvider(): CacheProvider;Defined in: CacheProvider.ts:15
Returns
CacheProvider
Accessors
ready
Get Signature
get abstract ready(): boolean;Defined in: CacheProvider.ts:48
Returns
boolean
Methods
clear()
clear(): Promise<void>;Defined in: CacheProvider.ts:65
Remove every entry this provider holds.
Returns
Promise<void>
del()
abstract del(key): Promise<unknown>;Defined in: CacheProvider.ts:34
Parameters
| Parameter | Type |
|---|---|
key | string | CacheKey | string[] |
Returns
Promise<unknown>
delMany()
delMany(keys): Promise<void>;Defined in: CacheProvider.ts:56
Delete many keys at once.
Conservative default: one at a time, with bounded concurrency so a large purge cannot open thousands of simultaneous operations.
Parameters
| Parameter | Type |
|---|---|
keys | (string | CacheKey)[] |
Returns
Promise<void>
get()
abstract get(key): Promise<unknown>;Defined in: CacheProvider.ts:21
Parameters
| Parameter | Type |
|---|---|
key | string | CacheKey |
Returns
Promise<unknown>
keys()
abstract keys(keysPrefix?): Promise<string[]>;Defined in: CacheProvider.ts:46
Every key this provider holds, without the store's configured keysPrefix and without any adapter-internal qualification.
The store passes its keysPrefix, and neither shipped provider reads it - the store filters and strips the prefix itself, because a provider that ignored the argument would otherwise return a superset and silently break that filtering. It stays in the signature so third-party providers that do use it to narrow their enumeration keep receiving it.
Parameters
| Parameter | Type |
|---|---|
keysPrefix? | string |
Returns
Promise<string[]>
set()
abstract set(
key,
val,
maxAge?): Promise<unknown>;Defined in: CacheProvider.ts:28
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | CacheKey | - |
val | unknown | - |
maxAge? | number | Milliseconds | in milliseconds. Do not convert: cache-manager's ttl is also milliseconds, and converting again is what made every entry outlive its configured lifetime by a factor of 1000. |
Returns
Promise<unknown>