UNSUBSCRIBE
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.
Return value
Section titled “Return value”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.
Examples
Section titled “Examples”127.0.0.1:6379> SUBSCRIBE news alerts1) "subscribe"2) "news"3) (integer) 11) "subscribe"2) "alerts"3) (integer) 2127.0.0.1:6379> UNSUBSCRIBE news1) "unsubscribe"2) "news"3) (integer) 1Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.