Skip to main content

DefaultCachePlugin

DefaultCachePlugin

This plugin provides a simple SQL-based cache strategy SqlCacheStrategy which stores cached items in the database.

It is suitable for production use (including multi-instance setups). For increased performance you can also consider using the RedisCachePlugin.

Signature
class DefaultCachePlugin {
static options: DefaultCachePluginInitOptions = {
cacheSize: 10_000,
};
init(options: DefaultCachePluginInitOptions) => ;
}

DefaultCachePluginInitOptions

Configuration options for the DefaultCachePlugin.

Signature
interface DefaultCachePluginInitOptions {
cacheSize?: number;
cacheTtlProvider?: CacheTtlProvider;
}

cacheSize

property
number
default:
10_000

The maximum number of items to store in the cache. Once the cache reaches this size, the least-recently-used items will be evicted to make room for new items.

cacheTtlProvider

property
CacheTtlProvider

Optionally provide a custom CacheTtlProvider to control the TTL of cache items. This is useful for testing.