function CachePlugin
Since 0.1.0
CachePlugin(options?: CachePluginOptions): IPlugin

Creates the CachePlugin.

Registers an ICacheStore under CAPABILITIES.CACHE (or cache.<name> when a custom name is provided for multi-cache setups).

Examples

Example 1

import { CachePlugin } from '@setu-ts/cache-plugin';

// Memory store (default)
app.register(CachePlugin());

// Redis store with URL
app.register(CachePlugin({
  store: 'redis',
  options: { url: 'redis://localhost:6379', prefix: 'myapp:' },
}));

// Named cache instance
app.register(CachePlugin({ name: 'session', options: { maxSize: 500 } }));

Parameters

optional
options: CachePluginOptions

Plugin configuration

Return Type

IPlugin

The plugin instance

Usage

import { CachePlugin } from "cache-plugin/src/index.ts";