EsRedisPubSubCommands
Description
Provides an API for the Redis Publish/Subscribe commands. Pub/Sub is a messaging pattern where senders (publishers) do not programmatically send messages to specific receivers (subscribers). Instead, published messages are characterized into channels, without knowledge of what subscribers there may be.
This command group is accessed via EsRedisClient>>pubsubs.
Class Methods
None
Instance Methods
psubscribe:
Listen for messages published to channels matching the given patterns.
Arguments:
aPatternOrCollection - <String | Collection> The pattern or patterns to subscribe to.
Answers:
<Array> A confirmation message.
<EsFuture> In async mode, a future that completes with the result.
publish:message:
Posts a message to the given channel.
Arguments:
aChannel - <String> The channel to publish to.
aMessage - <Object> The message to publish.
Answers:
<Integer> The number of clients that received the message.
<EsFuture> In async mode, a future that completes with the result.
pubsub:
Inspect the state of the Pub/Sub subsystem.
Arguments:
aSubcommand - <String> Can be CHANNELS, NUMSUB, or NUMPAT.
Answers:
<Array> A list of active channels, number of subscribers, or number of pattern subscribers.
<EsFuture> In async mode, a future that completes with the result.
pubsub:argument:
Inspect the state of the Pub/Sub subsystem with an argument.
Arguments:
aSubcommand - <String> Can be CHANNELS, NUMSUB.
anArgument - <String> An optional pattern for CHANNELS or channel names for NUMSUB.
Answers:
<Array> A list of active channels or number of subscribers for specific channels.
<EsFuture> In async mode, a future that completes with the result.
pubsubHelp
Get help text for the PUBSUB command.
Answers:
<Array> An array of strings containing help text.
<EsFuture> In async mode, a future that completes with the result.
pubsubShardChannels
Get active sharded channels.
Answers:
<Array> An array of active sharded channels.
<EsFuture> In async mode, a future that completes with the result.
pubsubShardNumsub:
Get the number of subscribers for sharded channels.
Arguments:
aCollectionOfChannels - <Collection> The sharded channels to query.
Answers:
<Dictionary> A dictionary mapping sharded channels to their subscriber counts.
<EsFuture> In async mode, a future that completes with the result.
punsubscribe:
Stop listening for messages posted to channels matching the given patterns.
Arguments:
aPatternOrCollection - <String | Collection> The pattern or patterns to unsubscribe from.
Answers:
<Array> A confirmation message.
<EsFuture> In async mode, a future that completes with the result.
spublish:message:
Publish a message to a sharded channel.
Arguments:
aChannel - <String> The sharded channel to publish to.
aMessage - <Object> The message to publish.
Answers:
<Integer> The number of clients that received the message.
<EsFuture> In async mode, a future that completes with the result.
subscribe:
Listen for messages published to the given channels.
Arguments:
aChannelOrCollection - <String | Collection> The channel or channels to subscribe to.
Answers:
<Array> A confirmation message.
<EsFuture> In async mode, a future that completes with the result.
unsubscribe:
Stop listening for messages posted to the given channels.
Arguments:
aChannelOrCollection - <String | Collection> The channel or channels to unsubscribe from.
Answers:
<Array> A confirmation message.
<EsFuture> In async mode, a future that completes with the result.
Last modified date: 01/22/2026