Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Effect KitRedis

How it works

Learn which services the client provides, which layer supplies each one, and what a reply looks like.

The client is a set of Effect services. Each service covers one kind of work, and the runtime layer decides which ones exist in your program.

Services

ServiceWhat it doesProvided by
RedisOrdinary commands, pipeline, transaction, execute, raw, scansRedisNode, RedisBun, RedisUpstash
RedisSessionsLeased connections: withSession, withBlockingSession, watch, blocking commandsRedisNode.layer, RedisBun.layer
RedisPubSubsubscribe, psubscribe, ssubscribeRedisNode.layer, RedisBun.layer
RedisStreamsContinuous stream readers and consumer groupsRedisNode.layer, RedisBun.layer
RedisScriptsLua scripts through EVALSHA with automatic loadRedisNode.layer, RedisBun.layer
RedisTracking, RedisCacheClient-side cachingAdded by you, see caching
RedisClusterCluster routing and per-node accessRedisNode.layerCluster, RedisBun.layerCluster
RedisSentinelPrimary discovery through SentinelRedisNode.layerSentinel, RedisBun.layerSentinel

Redis has no blocking commands, no WATCH and no subscriptions. Calling redis.blpop is a compile error, and running a blocking command through redis.execute fails with an UnsupportedCommandError. Those commands live on the other services because they hold a connection.

Connections and scope

A layer owns its connections. Building the layer opens the socket and runs the handshake, and closing the scope closes everything. Build it once and share it across your program.

One connection writes commands in order and matches replies to them in order. A command that has been written and then interrupted retires its connection, because the reply slot is no longer known. Cancelling a command does not undo it on the server.

Leased connections are separate. withSession borrows one from a pool and returns it when the body ends, including on interruption. See sessions.

Replies

Replies are decoded into plain types.

CommandSuccess type
redis.getOption<string>, strict UTF-8
redis.getBytesOption<Uint8Array>
redis.incr, redis.hset, redis.zadd, redis.delbigint
redis.hget, redis.lrangeOption<Uint8Array> and Uint8Array[], with hgetText returning Option<string>
redis.setvoid, or boolean with a condition

The delivery field

Errors from a command carry delivery, which says how far the command got.

ValueMeaning
unsentNothing was written. Safe to send again.
possibly-writtenThe write may have reached the server.
repliedThe server answered, for example with a ServerError.
unknownOver HTTP, the request may or may not have run.

The client never replays a command after possibly-written or unknown. See errors and retries.