Module: Redis::PubSub

Defined in:
lib/redis/pubsub.rb

Defined Under Namespace

Classes: Subscription

Instance Method Summary collapse

Instance Method Details

#redis_PSUBSCRIBE(*channels) ⇒ Object



123
124
125
126
127
128
129
130
# File 'lib/redis/pubsub.rb', line 123

def redis_PSUBSCRIBE *channels
  sub = @deferred
  sub = Subscription.new self unless Subscription === sub
  channels.each do |channel|
    sub.psubscribe channel
  end
  sub
end

#redis_PUBLISH(channel, message) ⇒ Object



145
146
147
# File 'lib/redis/pubsub.rb', line 145

def redis_PUBLISH channel, message
  Subscription.publish channel, message
end

#redis_PUNSUBSCRIBE(*channels) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/redis/pubsub.rb', line 132

def redis_PUNSUBSCRIBE *channels
  sub = @deferred
  sub = Subscription.new self unless Subscription === sub
  if channels.empty?
    sub.unbind_patterns
  else
    channels.each do |channel|
      sub.punsubscribe channel
    end
  end
  sub
end

#redis_SUBSCRIBE(*channels) ⇒ Object



101
102
103
104
105
106
107
108
# File 'lib/redis/pubsub.rb', line 101

def redis_SUBSCRIBE *channels
  sub = @deferred
  sub = Subscription.new self unless Subscription === sub
  channels.each do |channel|
    sub.subscribe channel
  end
  sub
end

#redis_UNSUBSCRIBE(*channels) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/redis/pubsub.rb', line 110

def redis_UNSUBSCRIBE *channels
  sub = @deferred
  sub = Subscription.new self unless Subscription === sub
  if channels.empty?
    sub.unbind_channels
  else
    channels.each do |channel|
      sub.unsubscribe channel
    end
  end
  sub
end