SUBSCRIBE
SUBSCRIBE channel [channel ...]
No method signature available for this client.
No method signature available for this client.
subscribe(
jedisPubSub: BinaryJedisPubSub, // Pub/sub listener object
channels: byte[]... // Channels to subscribe to
) → void // Blocks until unsubscribed
subscribe(
jedisPubSub: JedisPubSub, // Pub/sub listener object
channels: String... // Channels to subscribe to
) → void // Blocks until unsubscribed
No method signature available for this client.
No method signature available for this client.
No method signature available for this client.
No method signature available for this client.
No method signature available for this client.
No method signature available for this client.
No method signature available for this client.
No method signature available for this client.
No method signature available for this client.
- Available since:
- Redis Open Source 2.0.0
- Time complexity:
- O(N) where N is the number of channels to subscribe to.
- ACL categories:
-
@pubsub,@slow, - Compatibility:
- Redis Software and Redis Cloud compatibility
Subscribes the client to the specified channels.
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 subscribed state.
For more information, see Pub/sub.
Required arguments
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Standard |
✅ Standard |
Return information
subscribe is pushed as a confirmation that the command succeeded.
subscribe 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.
