NodeRedis unstable
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. Both also accept
Redis.PoolOptions for the connections behind Redis.reserve. node-redis
connects explicitly, so layer construction can fail with a RedisError.
Both layers close the client when the layer scope ends.
Layers
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 destroys the shared client immediately, failing commands
still in flight and aborting any connection attempt in progress, including
reserved connections that are still being established. Interrupting
Redis.subscribe while it is connecting or subscribing closes its
connection. Interrupting Redis.reserve only stops waiting: a connection the
pool is already opening joins the pool when it is ready. Run blocking
commands on Redis.reserve so they do not hold up the shared connection.
Signature
declare function layer(options?: any): Layer<NodeRedis | Redis, RedisError>layerConfig
unstableProvides 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 destroys the shared client immediately, failing commands
still in flight and aborting any connection attempt in progress, including
reserved connections that are still being established. Interrupting
Redis.subscribe while it is connecting or subscribing closes its
connection. Interrupting Redis.reserve only stops waiting: a connection the
pool is already opening joins the pool when it is ready. Run blocking
commands on Redis.reserve so they do not hold up the shared connection.
Signature
declare const layerConfig: (options: Config.Wrap<NodeRedisOptions>) => Layer.Layer<Redis.Redis | NodeRedis, Redis.RedisError | Config.ConfigError>Services
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);}