Module: Redis::Commands::Pubsub
- Included in:
- Redis::Commands
- Defined in:
- lib/redis/commands/pubsub.rb
Instance Method Summary collapse
-
#psubscribe(*channels, &block) ⇒ Object
Listen for messages published to channels matching the given patterns.
-
#psubscribe_with_timeout(timeout, *channels, &block) ⇒ Object
Listen for messages published to channels matching the given patterns.
-
#publish(channel, message) ⇒ Object
Post a message to a channel.
-
#pubsub(subcommand, *args) ⇒ Object
Inspect the state of the Pub/Sub subsystem.
-
#punsubscribe(*channels) ⇒ Object
Stop listening for messages posted to channels matching the given patterns.
-
#spublish(channel, message) ⇒ Object
Post a message to a channel in a shard.
-
#ssubscribe(*channels, &block) ⇒ Object
Listen for messages published to the given channels in a shard.
-
#ssubscribe_with_timeout(timeout, *channels, &block) ⇒ Object
Listen for messages published to the given channels in a shard.
-
#subscribe(*channels, &block) ⇒ Object
Listen for messages published to the given channels.
-
#subscribe_with_timeout(timeout, *channels, &block) ⇒ Object
Listen for messages published to the given channels.
- #subscribed? ⇒ Boolean
-
#sunsubscribe(*channels) ⇒ Object
Stop listening for messages posted to the given channels in a shard.
-
#unsubscribe(*channels) ⇒ Object
Stop listening for messages posted to the given channels.
Instance Method Details
#psubscribe(*channels, &block) ⇒ Object
Listen for messages published to channels matching the given patterns.
32 33 34 |
# File 'lib/redis/commands/pubsub.rb', line 32 def psubscribe(*channels, &block) _subscription(:psubscribe, 0, channels, block) end |
#psubscribe_with_timeout(timeout, *channels, &block) ⇒ Object
Listen for messages published to channels matching the given patterns. Throw a timeout error if there is no messages for a timeout period.
38 39 40 |
# File 'lib/redis/commands/pubsub.rb', line 38 def psubscribe_with_timeout(timeout, *channels, &block) _subscription(:psubscribe_with_timeout, timeout, channels, block) end |
#publish(channel, message) ⇒ Object
Post a message to a channel.
7 8 9 |
# File 'lib/redis/commands/pubsub.rb', line 7 def publish(channel, ) send_command([:publish, channel, ]) end |
#pubsub(subcommand, *args) ⇒ Object
Inspect the state of the Pub/Sub subsystem. Possible subcommands: channels, numsub, numpat.
49 50 51 |
# File 'lib/redis/commands/pubsub.rb', line 49 def pubsub(subcommand, *args) send_command([:pubsub, subcommand] + args) end |
#punsubscribe(*channels) ⇒ Object
Stop listening for messages posted to channels matching the given patterns.
43 44 45 |
# File 'lib/redis/commands/pubsub.rb', line 43 def punsubscribe(*channels) _subscription(:punsubscribe, 0, channels, nil) end |
#spublish(channel, message) ⇒ Object
Post a message to a channel in a shard.
54 55 56 |
# File 'lib/redis/commands/pubsub.rb', line 54 def spublish(channel, ) send_command([:spublish, channel, ]) end |
#ssubscribe(*channels, &block) ⇒ Object
Listen for messages published to the given channels in a shard.
59 60 61 |
# File 'lib/redis/commands/pubsub.rb', line 59 def ssubscribe(*channels, &block) _subscription(:ssubscribe, 0, channels, block) end |
#ssubscribe_with_timeout(timeout, *channels, &block) ⇒ Object
Listen for messages published to the given channels in a shard. Throw a timeout error if there is no messages for a timeout period.
65 66 67 |
# File 'lib/redis/commands/pubsub.rb', line 65 def ssubscribe_with_timeout(timeout, *channels, &block) _subscription(:ssubscribe_with_timeout, timeout, channels, block) end |
#subscribe(*channels, &block) ⇒ Object
Listen for messages published to the given channels.
16 17 18 |
# File 'lib/redis/commands/pubsub.rb', line 16 def subscribe(*channels, &block) _subscription(:subscribe, 0, channels, block) end |
#subscribe_with_timeout(timeout, *channels, &block) ⇒ Object
Listen for messages published to the given channels. Throw a timeout error if there is no messages for a timeout period.
22 23 24 |
# File 'lib/redis/commands/pubsub.rb', line 22 def subscribe_with_timeout(timeout, *channels, &block) _subscription(:subscribe_with_timeout, timeout, channels, block) end |
#subscribed? ⇒ Boolean
11 12 13 |
# File 'lib/redis/commands/pubsub.rb', line 11 def subscribed? !@subscription_client.nil? end |
#sunsubscribe(*channels) ⇒ Object
Stop listening for messages posted to the given channels in a shard.
70 71 72 |
# File 'lib/redis/commands/pubsub.rb', line 70 def sunsubscribe(*channels) _subscription(:sunsubscribe, 0, channels, nil) end |
#unsubscribe(*channels) ⇒ Object
Stop listening for messages posted to the given channels.
27 28 29 |
# File 'lib/redis/commands/pubsub.rb', line 27 def unsubscribe(*channels) _subscription(:unsubscribe, 0, channels, nil) end |