module Slanger::Redis

Public Instance Methods

hdel(*arg) click to toggle source
# File lib/slanger/redis.rb, line 33
def hdel(*arg)
  send_command :hdel, *arg
end
hgetall(*arg) click to toggle source
# File lib/slanger/redis.rb, line 37
def hgetall(*arg)
  send_command :hgetall, *arg
end
hincrby(*arg) click to toggle source
# File lib/slanger/redis.rb, line 25
def hincrby(*arg)
  send_command :hincrby, *arg
end
hset(*arg) click to toggle source
# File lib/slanger/redis.rb, line 29
def hset(*arg)
  send_command :hset, *arg
end
new_connection() click to toggle source
# File lib/slanger/redis.rb, line 59
def new_connection
  EM::Hiredis.connect Slanger::Config.redis_address
end
publish(*arg) click to toggle source
# File lib/slanger/redis.rb, line 41
def publish(*arg)
  publish_event(:publish, *arg)
end
publish_event(method, *args) click to toggle source
# File lib/slanger/redis.rb, line 45
def publish_event(method, *args)
  publisher.send(method, *args)
end
publisher() click to toggle source
# File lib/slanger/redis.rb, line 17
def publisher
  @publisher ||= new_connection
end
regular_connection() click to toggle source
# File lib/slanger/redis.rb, line 13
def regular_connection
  @regular_connection ||= new_connection
end
send_command(method, *arg) click to toggle source
# File lib/slanger/redis.rb, line 21
def send_command(method, *arg)
  regular_connection.send(method, *arg)
end
subscriber() click to toggle source
# File lib/slanger/redis.rb, line 49
def subscriber
  @subscriber ||= new_connection.pubsub.tap do |c|
    c.on(:message) do |channel, message|
      message = Oj.strict_load(message)
      c = Channel.from message["channel"]
      c.dispatch message, channel
    end
  end
end