Module: Lite::Redis::PubSubHelper

Included in:
PubSub, PubSub
Defined in:
lib/lite/redis/helpers/pub_sub_helper.rb

Instance Method Summary collapse

Instance Method Details

#match_subscribe(*channels, timeout: nil, &block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/lite/redis/helpers/pub_sub_helper.rb', line 27

def match_subscribe(*channels, timeout: nil, &block)
  if timeout.nil?
    client.psubscribe(*channels, &block)
  else
    client.psubscribe_with_timeout(timeout, *channels, &block)
  end
end

#match_unsubscribe(*channels) ⇒ Object



35
36
37
# File 'lib/lite/redis/helpers/pub_sub_helper.rb', line 35

def match_unsubscribe(*channels)
  client.punsubscribe(*channels)
end

#publish(channel, message) ⇒ Object



7
8
9
# File 'lib/lite/redis/helpers/pub_sub_helper.rb', line 7

def publish(channel, message)
  client.publish(channel, message)
end

#state(command, *args) ⇒ Object



39
40
41
# File 'lib/lite/redis/helpers/pub_sub_helper.rb', line 39

def state(command, *args)
  client.pubsub(command, *args)
end

#subscribe(*channels, timeout: nil, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/lite/redis/helpers/pub_sub_helper.rb', line 15

def subscribe(*channels, timeout: nil, &block)
  if timeout.nil?
    client.subscribe(*channels, &block)
  else
    client.subscribe_with_timeout(timeout, *channels, &block)
  end
end

#subscribed?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/lite/redis/helpers/pub_sub_helper.rb', line 11

def subscribed?
  client.subscribed?
end

#unsubscribe(*channels) ⇒ Object



23
24
25
# File 'lib/lite/redis/helpers/pub_sub_helper.rb', line 23

def unsubscribe(*channels)
  client.unsubscribe(*channels)
end