Skip to main content

cacheExtension()

cacheExtension(store, options?, transformers?): () => Extension

Creates a cache extension

Parameters

ParameterTypeDescription

store

Store

Storage adapter implementation

options?

DefaultStoreOptions

Default caching options

transformers?

SerializerTransformer[]

Serializer transformers for custom scalars that are not serializable by default

Returns

Extension factory function

(): Extension

Returns

Extension

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)
});