Skip to content

createRedisStorage

function createRedisStorage(options): RedisAuditStorage;

Defined in: src/storage/redis.ts:78

Create a Redis-backed RedisAuditStorage. Connection is lazy: the client is created/connected on the first storage operation and reused thereafter, guarded by a single connection promise so concurrent calls connect once.

Parameter Type
options RedisStorageOptions

RedisAuditStorage

import { createRedisStorage } from "@xtandard/audit/storage/redis";
const storage = createRedisStorage({
url: process.env.REDIS_URL ?? "redis://localhost:6379",
prefix: "myapp:audit",
onError: (err) => console.error("[audit/redis]", err),
});
// Disconnect when the process exits:
// process.on("SIGTERM", () => storage.close());