cacheExtension()
cacheExtension(
store
,options?
,transformers?
): () =>Extension
Creates a cache extension
Parameters
Parameter | Type | Description |
---|---|---|
|
Storage adapter implementation | |
|
Default caching options | |
|
Serializer transformers for custom scalars that are not serializable by default |
Returns
Extension factory function
():
Extension
Returns
Example
import { cacheExtension } from "@baeta/extension-cache";
import { RedisStore } from "@baeta/extension-cache-redis";
import Redis from "ioredis";
const redis = new Redis("redis://localhost:6379");
const redisStore = new RedisStore(redis);
export const cacheExt = cacheExtension(redisStore, {
ttl: 3600, // TTL in seconds (defaults to 1 hour)
});