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.

UNSUBSCRIBE

Last updated
UNSUBSCRIBE [channel [channel ...]]
Group
Pub/Sub
Complexity
O(N) for N channels
Arity
-1 (at least 1 words, counting the command name)
Flags
pubsub
HotKV Cloud
All plans
On-Premise
no license needed

UNSUBSCRIBE stops delivery from the given channels. Without arguments it unsubscribes from every channel the connection subscribed to with SUBSCRIBE. Pattern subscriptions (PSUBSCRIBE) and shard channel subscriptions (SSUBSCRIBE) are not affected.

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

Element Value
1 Bulk string unsubscribe
2 Bulk string: the channel
3 Integer: the number of channels and patterns still subscribed

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

127.0.0.1:6379> SUBSCRIBE news alerts
1) "subscribe"
2) "news"
3) (integer) 1
1) "subscribe"
2) "alerts"
3) (integer) 2
127.0.0.1:6379> UNSUBSCRIBE news
1) "unsubscribe"
2) "news"
3) (integer) 1

Same as Redis 7 and Valkey 8.

SUBSCRIBE, PUNSUBSCRIBE, SUNSUBSCRIBE