Class: Redis::SubscribedClient

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/subscribe.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ SubscribedClient

Returns a new instance of SubscribedClient.



5
6
7
8
# File 'lib/redis/subscribe.rb', line 5

def initialize(client)
  @client = client
  @write_monitor = Monitor.new
end

Instance Method Details

#call_v(command) ⇒ Object



10
11
12
13
14
# File 'lib/redis/subscribe.rb', line 10

def call_v(command)
  @write_monitor.synchronize do
    @client.call_v(command)
  end
end

#closeObject



40
41
42
# File 'lib/redis/subscribe.rb', line 40

def close
  @client.close
end

#psubscribe(*channels, &block) ⇒ Object



24
25
26
# File 'lib/redis/subscribe.rb', line 24

def psubscribe(*channels, &block)
  subscription("psubscribe", "punsubscribe", channels, block)
end

#psubscribe_with_timeout(timeout, *channels, &block) ⇒ Object



28
29
30
# File 'lib/redis/subscribe.rb', line 28

def psubscribe_with_timeout(timeout, *channels, &block)
  subscription("psubscribe", "punsubscribe", channels, block, timeout)
end

#punsubscribe(*channels) ⇒ Object



36
37
38
# File 'lib/redis/subscribe.rb', line 36

def punsubscribe(*channels)
  call_v([:punsubscribe, *channels])
end

#subscribe(*channels, &block) ⇒ Object



16
17
18
# File 'lib/redis/subscribe.rb', line 16

def subscribe(*channels, &block)
  subscription("subscribe", "unsubscribe", channels, block)
end

#subscribe_with_timeout(timeout, *channels, &block) ⇒ Object



20
21
22
# File 'lib/redis/subscribe.rb', line 20

def subscribe_with_timeout(timeout, *channels, &block)
  subscription("subscribe", "unsubscribe", channels, block, timeout)
end

#unsubscribe(*channels) ⇒ Object



32
33
34
# File 'lib/redis/subscribe.rb', line 32

def unsubscribe(*channels)
  call_v([:unsubscribe, *channels])
end