Skip to content

@btravstack/cache


@btravstack/cache / redis

redis

Classes

CacheConfig

Defined in: packages/cache/src/redis.ts:15

What the graph bound from the environment for the Redis adapter.

Extends

  • PortInstance<"CacheConfig", { url: string; }>

Constructors

Constructor
ts
new CacheConfig(): CacheConfig;

Defined in: packages/di/dist/index.d.mts:16

Returns

CacheConfig

Inherited from
ts
Port("CacheConfig")<{ readonly url: string }>.constructor

Properties

PropertyModifierTypeInherited fromDefined in
[ID]readonly"CacheConfig"Port("CacheConfig").[ID]packages/di/dist/index.d.mts:12
[SERVICE]readonlyobjectPort("CacheConfig").[SERVICE]packages/di/dist/index.d.mts:13
[SERVICE].urlreadonlystring-packages/cache/src/redis.ts:15
portIdreadonly"CacheConfig"Port("CacheConfig").portIdpackages/di/dist/index.d.mts:17

Variables

redisSchema

ts
const redisSchema: ConfigSchema<Readonly<Record<string, string | undefined>>, {
  url: string;
}>;

Defined in: packages/cache/src/redis.ts:22

REDIS_URL, required. No default: a cache quietly pointed at localhost would look like it was working. An unset variable is a ConfigInvalid naming it, at graph build.

Functions

redisCache()

ts
function redisCache(): Module<CacheBackend, ConfigInvalid, Env | Scope>;

Defined in: packages/cache/src/redis.ts:65

The Redis adapter: one connection, opened with the scope and closed with it, and CacheBackend over it. Nothing here is per call — a client per operation would spend a handshake to save nothing and leave the drain with sockets it does not know about.

Returns

Module<CacheBackend, ConfigInvalid, Env | Scope>


redisCacheBackend()

ts
function redisCacheBackend(client): CacheBackendService;

Defined in: packages/cache/src/redis.ts:38

The adapter's service over a connected client. Values are JSON, which is what every other reader of that database already speaks. A value JSON.stringify cannot take is a defect, not a CacheUnavailable: a bug in the caller, and an arm no correct program could reach.

Parameters

ParameterType
clientRedisClientType

Returns

CacheBackendService

Released under the MIT License.