psubscribe.3valkey - Man Page
Listens for messages published to channels that match one or more patterns.
Synopsis
PSUBSCRIBE pattern [pattern...]
Description
Subscribes the client to the given patterns.
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.
Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional valkey-subscribe(7) SUBSCRIBE, valkey-ssubscribe(7) SSUBSCRIBE, PSUBSCRIBE, valkey-unsubscribe(7) UNSUBSCRIBE, valkey-sunsubscribe(7) SUNSUBSCRIBE, valkey-punsubscribe(7) PUNSUBSCRIBE, valkey-ping(7) PING, valkey-reset(7) RESET and valkey-quit(7) QUIT commands. However, if RESP3 is used (see valkey-hello(7) HELLO) it is possible for a client to issue any commands while in subscribed state.
Note that valkey-reset(7) RESET can be called to exit subscribed state.
For more information, see valkey-pubsub(7) Pub/sub.
Reply
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.
Complexity
O(N) where N is the number of patterns to subscribe to.
Acl Categories
@pubsub @slow
History
- Available since: 2.0.0
See Also
publish(3valkey), pubsub(3valkey), pubsub-channels(3valkey), pubsub-help(3valkey), pubsub-numpat(3valkey), pubsub-numsub(3valkey), pubsub-shardchannels(3valkey), pubsub-shardnumsub(3valkey), punsubscribe(3valkey), spublish(3valkey), ssubscribe(3valkey), subscribe(3valkey), sunsubscribe(3valkey), unsubscribe(3valkey)