PSUBSCRIBE
PSUBSCRIBE pattern [pattern ...]
- Available since:
- Redis Open Source 2.0.0
- Time complexity:
- O(N) where N is the number of patterns to subscribe to.
- ACL categories:
-
@pubsub,@slow, - Compatibility:
- Redis Software and Redis Cloud compatibility
Subscribes the client to the given patterns.
Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional SUBSCRIBE, SSUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, SUNSUBSCRIBE, PUNSUBSCRIBE, PING, RESET and QUIT commands.
However, if RESP3 is used (see HELLO), it is possible for a client to issue any commands while in a subscribed state.
For more information, see Pub/sub.
Required arguments
pattern [pattern ...]
One or more glob-style patterns to subscribe to. Messages published to any channel whose name matches a pattern are delivered to the client.
Supported glob-style patterns:
h?llosubscribes tohello,halloandhxlloh*llosubscribes tohlloandheeeelloh[ae]llosubscribes tohelloandhallo,but nothillo
Use \ to escape special characters if you want to match them verbatim.
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Standard |
✅ Standard |
Return information
When successful, this command doesn't return anything. Instead, for each pattern, one message with the first element being the string
psubscribe is pushed as a confirmation that the command succeeded.
History
- Starting with Redis version 6.2.0: RESET can be called to exit the subscribed state.