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

Pub/Sub

Look up the publish and inspection commands on Redis and the subscribe methods on RedisPubSub.

Publishing and inspecting channels are ordinary commands on the Redis service. Subscribing holds a connection open, so it lives on RedisPubSub.

Example (Publishing and Subscribing)

import { ,  } from "effect";

import { ,  } from "@effect-kit/redis";

const  = .(
  .(function* () {
    const  = yield* ;
    const  = yield* ;

    const  = yield* .(["orders"]);

    const receivers = yield* .("orders", "order-1");
const receivers: bigint
const first = yield* ..(.(1), .);
const first: PubSubMessage[]
return { , }; }), );

subscribe needs a Scope and closes the subscription when the scope ends. For delivery gaps, limits and reconnects, see Pub/Sub.

Methods on Redis

MethodCommandReply typePurpose
redis.publishPUBLISHbigintPublish a message to a channel and return the receiver count.
redis.spublishSPUBLISHbigintPublish a message to a shard channel.
redis.pubsubChannelsPUBSUB CHANNELSreadonly Uint8Array[]List active channels, optionally by pattern.
redis.pubsubNumSubPUBSUB NUMSUBreadonly (readonly [Uint8Array, bigint])[]Count subscribers per channel.
redis.pubsubNumPatPUBSUB NUMPATbigintCount pattern subscriptions.
redis.pubsubShardChannelsPUBSUB SHARDCHANNELSreadonly Uint8Array[]List active shard channels.
redis.pubsubShardNumSubPUBSUB SHARDNUMSUBreadonly (readonly [Uint8Array, bigint])[]Count subscribers per shard channel.
redis.pubsubHelpPUBSUB HELPreadonly string[]Return the PUBSUB help text.

Methods on RedisPubSub

MethodCommandReply typePurpose
pubsub.subscribeSUBSCRIBE{ events; messages; close }Subscribe to channels. mode: "pattern" or "shard" sends PSUBSCRIBE or SSUBSCRIBE.
pubsub.psubscribePSUBSCRIBE{ events; messages; close }Subscribe to patterns.
pubsub.ssubscribeSSUBSCRIBE{ events; messages; close }Subscribe to shard channels.
pubsub.unknownPushesnoneStream<{ generation; value: RespValue }>Pushes the client did not recognize.
pubsub.snapshotnoneEffect<{ generation; listeners; retiring; interests; retainedBytes }>Counters for the current connection.

subscribe, psubscribe and ssubscribe return an Effect that needs a Scope. events carries Ready and DeliveryGap events as well as messages. messages carries only messages and fails with a SubscriptionError on a gap.

SubscribeOptions

Prop

Type

PubSubMessage has _tag of "Message", "PatternMessage" or "ShardMessage", plus channel: Uint8Array, payload: Uint8Array, attributes and generation. PatternMessage also has pattern. SubscriptionEvent adds { _tag: "Ready" } and { _tag: "DeliveryGap" }.

Subscription limits are set under subscriptions. Upstash has no RedisPubSub. Use UpstashEvents.subscribe from @effect-kit/redis/upstash, which takes one channel and yields text.