class Msngr::Clients::Redis
Attributes
args[R]
(Connectivity) Arguments to initialize the Redis
instance with.
@return [Array]
Public Class Methods
new(*args)
click to toggle source
Instantiances an instance of Msngr::Clients::Redis
.
@param [Array] *args the arguments to pass in to the Redis
client.
# File lib/msngr/clients/redis.rb, line 15 def initialize(*args) @args = args end
Public Instance Methods
on_message() { |event, message| ... }
click to toggle source
Yields all events/messages from the Redis
server.
@yield [event, message] @yieldparam [String] event the name of the received event. @yieldparam [String] message the message of the received event.
@note This is an interface for Msngr::Messenger
.
# File lib/msngr/clients/redis.rb, line 27 def on_message connection.psubscribe("*") do |on| on.pmessage { |_, event, message| yield event, message } end end
Private Instance Methods
connection()
click to toggle source
Creates and returns a new instance of Redis
using @args if present.
@return [Redis]
# File lib/msngr/clients/redis.rb, line 39 def connection if args.any? Redis.new(*args) else Redis.new end end