Skip to content
Effect Days 2026 Get your ticket

NodeRedis

Node.js Redis integration backed by redis (node-redis).

This module creates a scoped node-redis client and exposes it in two forms: the generic Redis service and the NodeRedis service for direct access to the underlying client. layer accepts node-redis client options directly, while layerConfig reads them from Effect config. node-redis connects explicitly, so layer construction can fail with a RedisError. Both layers close the client when the layer scope ends.

3 exports Added in v4.0.0 Source

Layers

layer

Added in v4.0.0 Source

Provides Redis and NodeRedis services backed by a node-redis client created with the supplied options, connected when the layer is built and closed when the layer scope ends.

Details

By default, the initial connection fails on its first connection error. A caller-supplied socket.reconnectStrategy is used instead when present. Once the client has emitted ready, the default reconnect strategy uses node-redis' exponential backoff and stops on socket timeouts.

Scope finalization calls close(), which waits for in-flight commands, including blocking commands, and can therefore delay scope closure.

Signature

declare function layer(options?: any): Layer<NodeRedis | Redis, RedisError>

layerConfig

Added in v4.0.0 Source

Provides Redis and NodeRedis services from Config-backed node-redis client options, connecting the client when the layer is built and closing it when the layer scope ends.

Details

By default, the initial connection fails on its first connection error. A caller-supplied socket.reconnectStrategy is used instead when present. Once the client has emitted ready, the default reconnect strategy uses node-redis' exponential backoff and stops on socket timeouts.

Scope finalization calls close(), which waits for in-flight commands, including blocking commands, and can therefore delay scope closure.

Signature

declare const layerConfig: (options: Config.Wrap<NodeRedisClientOptions>) => Layer.Layer<Redis.Redis | NodeRedis, Redis.RedisError | Config.ConfigError>

Services

NodeRedis

Added in v4.0.0 Source

Service tag for the Node Redis integration, exposing the underlying node-redis client and a use helper that maps client failures to RedisError.

Signature

declare class NodeRedis extends Shape<"@effect/platform-node/NodeRedis", {
readonly client: any;
readonly use: <A>(f: (client: any) => Promise<A>) => Effect<A, RedisError>;
}, this> {
constructor(_: never);
}