class Async::Redis::Context::Subscribe
Constants
- MESSAGE
Public Class Methods
new(pool, channels)
click to toggle source
Calls superclass method
Async::Redis::Context::Generic::new
# File lib/async/redis/context/subscribe.rb, line 32 def initialize(pool, channels) super(pool) subscribe(channels) end
Public Instance Methods
close()
click to toggle source
Calls superclass method
Async::Redis::Context::Generic#close
# File lib/async/redis/context/subscribe.rb, line 38 def close # There is no way to reset subscription state. On Redis v6+ you can use RESET, but this is not supported in <= v6. @connection&.close super end
listen()
click to toggle source
# File lib/async/redis/context/subscribe.rb, line 45 def listen while response = @connection.read_response return response if response.first == MESSAGE end end
subscribe(channels)
click to toggle source
# File lib/async/redis/context/subscribe.rb, line 51 def subscribe(channels) @connection.write_request ['SUBSCRIBE', *channels] @connection.flush end
unsubscribe(channels)
click to toggle source
# File lib/async/redis/context/subscribe.rb, line 56 def unsubscribe(channels) @connection.write_request ['UNSUBSCRIBE', *channels] @connection.flush end