createRedisJSONStorage
function createRedisJSONStorage(options): RedisAuditStorage;Defined in: src/storage/redis.ts:106
Create a Redis-backed RedisAuditStorage that stores values as native
RedisJSON documents (JSON.SET/JSON.GET) instead of strings — making
the stored records queryable with JSONPath (JSON.GET key $.action) and
indexable with RediSearch, while the audit system behaves identically.
Requires the JSON module on the server (built into Redis 8; Redis Stack; or
redisjson loaded). Same options and semantics as createRedisStorage,
including lazy connection, SCAN-based getKeys, keyspace-notification
watch, and the Lua compareAndSwap. Do not point it at keys written by
createRedisStorage (or vice versa) — the underlying types differ and
Redis answers WRONGTYPE.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
RedisStorageOptions |
Returns
Section titled “Returns”Example
Section titled “Example”import { createRedisJSONStorage } from "@xtandard/audit/storage/redis";
const storage = createRedisJSONStorage({ url: process.env.REDIS_URL ?? "redis://localhost:6379", prefix: "myapp:audit",});// Then, in redis-cli: JSON.GET myapp:audit:aud/t/acme/events/000000000001 $.action