Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

SUNSUBSCRIBE

Last updated
SUNSUBSCRIBE [shardchannel [shardchannel ...]]
Group
Pub/Sub
Complexity
O(N) for N shard channels
Arity
-1 (at least 1 words, counting the command name)
Flags
pubsub
Keys
first 1, last final argument, step 1
HotKV Cloud
All plans
On-Premise
no license needed

SUNSUBSCRIBE removes the given shard channel subscriptions. Without arguments it removes every shard channel subscription of the connection, and leaves channel and pattern subscriptions alone.

One confirmation per shard channel removed (or per shard channel named):

Element Value
1 Bulk string sunsubscribe
2 Bulk string: the shard channel
3 Integer: the number of shard channels still subscribed

When called without arguments and the connection has no shard channel subscriptions, a single confirmation is sent with a nil channel and a count of 0. On RESP3 the confirmations are push messages.

127.0.0.1:6379> SSUBSCRIBE orders:{eu}
1) "ssubscribe"
2) "orders:{eu}"
3) (integer) 1
127.0.0.1:6379> SUNSUBSCRIBE orders:{eu}
1) "sunsubscribe"
2) "orders:{eu}"
3) (integer) 0

Same as Redis 7 and Valkey 8.

SSUBSCRIBE, UNSUBSCRIBE