Module: Valkey::Commands::PubSubCommands
- Included in:
- Valkey::Commands
- Defined in:
- lib/valkey/commands/pubsub_commands.rb
Overview
This module contains commands related to Valkey Pub/Sub.
Instance Method Summary collapse
-
#psubscribe(*patterns) ⇒ String
Subscribe to one or more patterns.
-
#publish(channel, message) ⇒ Integer
Publish a message to a channel.
-
#pubsub(subcommand, *args) ⇒ Object
Control pub/sub operations (convenience method).
-
#pubsub_channels(pattern = nil) ⇒ Array<String>
List active channels.
-
#pubsub_numpat ⇒ Integer
Get the number of unique patterns subscribed to.
-
#pubsub_numsub(*channels) ⇒ Array
Get the number of subscribers for channels.
-
#pubsub_shardchannels(pattern = nil) ⇒ Array<String>
List active shard channels.
-
#pubsub_shardnumsub(*channels) ⇒ Array
Get the number of subscribers for shard channels.
-
#punsubscribe(*patterns) ⇒ String
Unsubscribe from one or more patterns.
-
#spublish(channel, message) ⇒ Integer
Publish a message to a shard channel.
-
#ssubscribe(*channels) ⇒ String
Subscribe to one or more shard channels.
-
#subscribe(*channels) ⇒ String
Subscribe to one or more channels.
-
#sunsubscribe(*channels) ⇒ String
Unsubscribe from one or more shard channels.
-
#unsubscribe(*channels) ⇒ String
Unsubscribe from one or more channels.
Instance Method Details
#psubscribe(*patterns) ⇒ String
Subscribe to one or more patterns.
51 52 53 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 51 def psubscribe(*patterns) send_command(RequestType::PSUBSCRIBE, patterns) end |
#publish(channel, message) ⇒ Integer
Publish a message to a channel.
83 84 85 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 83 def publish(channel, ) send_command(RequestType::PUBLISH, [channel, ]) end |
#pubsub(subcommand, *args) ⇒ Object
Control pub/sub operations (convenience method).
231 232 233 234 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 231 def pubsub(subcommand, *args) subcommand = subcommand.to_s.downcase send("pubsub_#{subcommand}", *args) end |
#pubsub_channels(pattern = nil) ⇒ Array<String>
List active channels.
146 147 148 149 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 146 def pubsub_channels(pattern = nil) args = pattern ? [pattern] : [] send_command(RequestType::PUBSUB_CHANNELS, args) end |
#pubsub_numpat ⇒ Integer
Get the number of unique patterns subscribed to.
160 161 162 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 160 def pubsub_numpat send_command(RequestType::PUBSUB_NUM_PAT) end |
#pubsub_numsub(*channels) ⇒ Array
Get the number of subscribers for channels.
174 175 176 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 174 def pubsub_numsub(*channels) send_command(RequestType::PUBSUB_NUM_SUB, channels) end |
#pubsub_shardchannels(pattern = nil) ⇒ Array<String>
List active shard channels.
191 192 193 194 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 191 def pubsub_shardchannels(pattern = nil) args = pattern ? [pattern] : [] send_command(RequestType::PUBSUB_SHARD_CHANNELS, args) end |
#pubsub_shardnumsub(*channels) ⇒ Array
Get the number of subscribers for shard channels.
206 207 208 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 206 def pubsub_shardnumsub(*channels) send_command(RequestType::PUBSUB_SHARD_NUM_SUB, channels) end |
#punsubscribe(*patterns) ⇒ String
Unsubscribe from one or more patterns.
68 69 70 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 68 def punsubscribe(*patterns) send_command(RequestType::PUNSUBSCRIBE, patterns) end |
#spublish(channel, message) ⇒ Integer
Publish a message to a shard channel.
129 130 131 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 129 def spublish(channel, ) send_command(RequestType::SPUBLISH, [channel, ]) end |
#ssubscribe(*channels) ⇒ String
Subscribe to one or more shard channels.
97 98 99 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 97 def ssubscribe(*channels) send_command(RequestType::SSUBSCRIBE, channels) end |
#subscribe(*channels) ⇒ String
Subscribe to one or more channels.
20 21 22 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 20 def subscribe(*channels) send_command(RequestType::SUBSCRIBE, channels) end |
#sunsubscribe(*channels) ⇒ String
Unsubscribe from one or more shard channels.
114 115 116 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 114 def sunsubscribe(*channels) send_command(RequestType::SUNSUBSCRIBE, channels) end |
#unsubscribe(*channels) ⇒ String
Unsubscribe from one or more channels.
37 38 39 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 37 def unsubscribe(*channels) send_command(RequestType::UNSUBSCRIBE, channels) end |