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. Pub/Sub is not yet supported and is partially implemented. TODO: https://github.com/valkey-io/valkey-glide-ruby/issues/135
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) ⇒ Hash
Get the number of subscribers for channels.
-
#pubsub_shardchannels(pattern = nil) ⇒ Array<String>
List active shard channels.
-
#pubsub_shardnumsub(*channels) ⇒ Hash
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.
53 54 55 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 53 def psubscribe(*patterns) send_command(RequestType::PSUBSCRIBE, patterns) end |
#publish(channel, message) ⇒ Integer
Publish a message to a channel.
85 86 87 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 85 def publish(channel, ) send_command(RequestType::PUBLISH, [channel, ]) end |
#pubsub(subcommand, *args) ⇒ Object
Control pub/sub operations (convenience method).
233 234 235 236 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 233 def pubsub(subcommand, *args) subcommand = subcommand.to_s.downcase send("pubsub_#{subcommand}", *args) end |
#pubsub_channels(pattern = nil) ⇒ Array<String>
List active channels.
148 149 150 151 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 148 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.
162 163 164 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 162 def pubsub_numpat send_command(RequestType::PUBSUB_NUM_PAT) end |
#pubsub_numsub(*channels) ⇒ Hash
Get the number of subscribers for channels.
176 177 178 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 176 def pubsub_numsub(*channels) send_command(RequestType::PUBSUB_NUM_SUB, channels) end |
#pubsub_shardchannels(pattern = nil) ⇒ Array<String>
List active shard channels.
193 194 195 196 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 193 def pubsub_shardchannels(pattern = nil) args = pattern ? [pattern] : [] send_command(RequestType::PUBSUB_SHARD_CHANNELS, args) end |
#pubsub_shardnumsub(*channels) ⇒ Hash
Get the number of subscribers for shard channels.
208 209 210 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 208 def pubsub_shardnumsub(*channels) send_command(RequestType::PUBSUB_SHARD_NUM_SUB, channels) end |
#punsubscribe(*patterns) ⇒ String
Unsubscribe from one or more patterns.
70 71 72 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 70 def punsubscribe(*patterns) send_command(RequestType::PUNSUBSCRIBE, patterns) end |
#spublish(channel, message) ⇒ Integer
Publish a message to a shard channel.
131 132 133 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 131 def spublish(channel, ) send_command(RequestType::SPUBLISH, [channel, ]) end |
#ssubscribe(*channels) ⇒ String
Subscribe to one or more shard channels.
99 100 101 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 99 def ssubscribe(*channels) send_command(RequestType::SSUBSCRIBE, channels) end |
#subscribe(*channels) ⇒ String
Subscribe to one or more channels.
22 23 24 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 22 def subscribe(*channels) send_command(RequestType::SUBSCRIBE, channels) end |
#sunsubscribe(*channels) ⇒ String
Unsubscribe from one or more shard channels.
116 117 118 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 116 def sunsubscribe(*channels) send_command(RequestType::SUNSUBSCRIBE, channels) end |
#unsubscribe(*channels) ⇒ String
Unsubscribe from one or more channels.
39 40 41 |
# File 'lib/valkey/commands/pubsub_commands.rb', line 39 def unsubscribe(*channels) send_command(RequestType::UNSUBSCRIBE, channels) end |