PUNSUBSCRIBE
PUNSUBSCRIBE [pattern [pattern ...]]
- Group
- Pub/Sub
- Complexity
- O(N) for N patterns
- Arity
- -1 (at least 1 words, counting the command name)
- Flags
- pubsub
- HotKV Cloud
- All plans
- On-Premise
- no license needed
PUNSUBSCRIBE removes the given pattern subscriptions. The pattern must be
written exactly as it was passed to PSUBSCRIBE; it is
not matched against other patterns. Without arguments it removes every pattern
subscription of the connection, and leaves channel and shard channel
subscriptions alone.
Return value
Section titled “Return value”One confirmation per pattern removed (or per pattern named):
| Element | Value |
|---|---|
| 1 | Bulk string punsubscribe |
| 2 | Bulk string: the pattern |
| 3 | Integer: the number of channels and patterns still subscribed |
When called without arguments and the connection has no pattern subscriptions, a single confirmation is sent with a nil pattern. On RESP3 the confirmations are push messages.
Examples
Section titled “Examples”127.0.0.1:6379> PSUBSCRIBE news.* alerts.*1) "psubscribe"2) "news.*"3) (integer) 11) "psubscribe"2) "alerts.*"3) (integer) 2127.0.0.1:6379> PUNSUBSCRIBE alerts.*1) "punsubscribe"2) "alerts.*"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.