Module: Slanger::Redis

Extended by:
Forwardable, Redis
Included in:
Redis
Defined in:
lib/slanger/redis.rb

Instance Method Summary collapse

Instance Method Details

#channel_attend(*arg) ⇒ Object



41
42
43
# File 'lib/slanger/redis.rb', line 41

def channel_attend(*arg)
  send_command :channel_attend, *arg
end

#channel_leave(*arg) ⇒ Object



37
38
39
# File 'lib/slanger/redis.rb', line 37

def channel_leave(*arg)
  send_command :channel_leave, *arg
end

#hdel(*arg) ⇒ Object



33
34
35
# File 'lib/slanger/redis.rb', line 33

def hdel(*arg)
  send_command :hdel, *arg
end

#hgetall(*arg) ⇒ Object



45
46
47
# File 'lib/slanger/redis.rb', line 45

def hgetall(*arg)
  send_command :hgetall, *arg
end

#hincrby(*arg) ⇒ Object



25
26
27
# File 'lib/slanger/redis.rb', line 25

def hincrby(*arg)
  send_command :hincrby, *arg
end

#hset(*arg) ⇒ Object



29
30
31
# File 'lib/slanger/redis.rb', line 29

def hset(*arg)
  send_command :hset, *arg
end

#new_connectionObject



67
68
69
# File 'lib/slanger/redis.rb', line 67

def new_connection
  EM::Hiredis.connect Slanger::Config.redis_address
end

#publish(*arg) ⇒ Object



49
50
51
# File 'lib/slanger/redis.rb', line 49

def publish(*arg)
  publish_event(:publish, *arg)
end

#publish_event(method, *args) ⇒ Object



53
54
55
# File 'lib/slanger/redis.rb', line 53

def publish_event(method, *args)
  publisher.send(method, *args)
end

#publisherObject



17
18
19
# File 'lib/slanger/redis.rb', line 17

def publisher
  @publisher ||= new_connection
end

#regular_connectionObject



13
14
15
# File 'lib/slanger/redis.rb', line 13

def regular_connection
  @regular_connection ||= new_connection
end

#send_command(method, *arg) ⇒ Object



21
22
23
# File 'lib/slanger/redis.rb', line 21

def send_command(method, *arg)
  regular_connection.send(method, *arg)
end

#subscriberObject



57
58
59
60
61
62
63
64
65
# File 'lib/slanger/redis.rb', line 57

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