Skip to content

RedisCacheOptions

Defined in: src/cache/RedisCache.ts:28

Redis-backed Cache — wraps ioredis. We pick ioredis over the official redis client because it’s better typed, supports Redis Cluster out of the box, and is the de-facto choice in the Node ecosystem. ioredis is a lazy optional peer dependency: it’s imported on first cache operation, so users who don’t reach for the Redis backend pay nothing.

Values are JSON-serialized on set, JSON-parsed on get. This matches 95% of cache use-cases (config, response bodies, counters). Binary payloads or other formats need a custom Cache implementation — deliberately out of scope for v1.

Connection failures do not throw from get — they return None. The caller’s recovery path (re-fetch from source-of-truth) is the right behaviour for a cache miss. set and delete swallow transient errors too, since lost cache writes are tolerable by definition. incr and setIfAbsent do throw because the caller relies on their atomic semantics for correctness (rate-limit, idempotency-key).

readonly optional client?: RedisClientLike

Defined in: src/cache/RedisCache.ts:47

Pre-built ioredis client — bypass internal construction (advanced usage: connection sharing, custom retry strategies, Redis Cluster).


readonly optional db?: number

Defined in: src/cache/RedisCache.ts:37


readonly optional host?: string

Defined in: src/cache/RedisCache.ts:34


readonly optional keyPrefix?: string

Defined in: src/cache/RedisCache.ts:42

Optional key prefix prepended to every key. Useful when a single Redis instance is shared by multiple actor systems / environments.


readonly optional password?: string

Defined in: src/cache/RedisCache.ts:36


readonly optional port?: number

Defined in: src/cache/RedisCache.ts:35


readonly optional url?: string

Defined in: src/cache/RedisCache.ts:33

Redis URL (e.g. redis://localhost:6379) — passed straight to the ioredis constructor. Mutually exclusive with host/port.