SSUBSCRIBE · Valkey

SSUBSCRIBE

Listens for messages published to shard channels.

Usage

SSUBSCRIBE shardchannel [shardchannel…]

Description

Subscribes the client to the specified shard channels.

In a Valkey cluster, shard channels are assigned to slots by the same algorithm used to assign keys to slots. Client(s) can subscribe to a node covering a slot (primary/replica) to receive the messages published. All the specified shard channels needs to belong to a single slot to subscribe in a given SSUBSCRIBE call, A client can subscribe to channels across different slots over separate SSUBSCRIBE call.

For more information about sharded Pub/Sub, see Sharded Pub/Sub.

Reply RESP2

When successful, this command doesn’t return anything. Instead, for each shard channel, one message with the first element being the string ssubscribe is pushed as a confirmation that the command succeeded. Note that this command can also return a -MOVED redirect.

Reply RESP3

When successful, this command doesn’t return anything. Instead, for each shard channel, one message with the first element being the string ‘ssubscribe’ is pushed as a confirmation that the command succeeded. Note that this command can also return a -MOVED redirect.

Complexity

O(N) where N is the number of shard channels to subscribe to.

ACL Categories

@pubsub @slow

Examples

> ssubscribe orders
Reading messages... (press Ctrl-C to quit)
1) "ssubscribe"
2) "orders"
3) (integer) 1
1) "smessage"
2) "orders"
3) "hello"

History

See also

PSUBSCRIBE, PUBLISH, PUBSUB, PUBSUB CHANNELS, PUBSUB HELP, PUBSUB NUMPAT, PUBSUB NUMSUB, PUBSUB SHARDCHANNELS, PUBSUB SHARDNUMSUB, PUNSUBSCRIBE, SPUBLISH, SUBSCRIBE, SUNSUBSCRIBE, UNSUBSCRIBE.