Skip to content

createRedisJSONStorage

function createRedisJSONStorage(options): RedisFlagsStorage;

Defined in: storage/redis.ts:90

Create a Redis-backed RedisFlagsStorage that stores values as native RedisJSON documents (JSON.SET/JSON.GET) instead of strings — making the stored snapshots/drafts queryable with JSONPath (JSON.GET key $.flags) and indexable with RediSearch, while the flags 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, and keyspace-notification watch. Do not point it at keys written by createRedisStorage (or vice versa) — the underlying types differ and Redis answers WRONGTYPE.

Parameter Type
options RedisStorageOptions

RedisFlagsStorage

import { createRedisJSONStorage } from "@xtandard/flags/storage/redis";
const storage = createRedisJSONStorage({
url: process.env.REDIS_URL ?? "redis://localhost:6379",
prefix: "myapp:flags",
});
// Then, in redis-cli: JSON.GET myapp:flags:flags/default/production/snapshots/v1 $.flags