Class: MessageChannel
- Inherits:
-
RedisConnection
- Object
- RedisConnection
- MessageChannel
- Defined in:
- lib/redis_store.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Attributes inherited from RedisConnection
Instance Method Summary collapse
-
#initialize(channel) ⇒ MessageChannel
constructor
A new instance of MessageChannel.
- #publish(message) ⇒ Object
- #subscribe(&proc) ⇒ Object
- #to_s ⇒ Object
Methods inherited from RedisConnection
Constructor Details
#initialize(channel) ⇒ MessageChannel
Returns a new instance of MessageChannel.
111 112 113 114 |
# File 'lib/redis_store.rb', line 111 def initialize channel @channel = channel super end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
109 110 111 |
# File 'lib/redis_store.rb', line 109 def channel @channel end |
Instance Method Details
#publish(message) ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/redis_store.rb', line 122 def publish redis.pipelined do @redis.hincrby "counters", @channel, 1 #@redis.hincrby "ts:counters", keygen+"_count", 1 @redis.publish(@channel, ) end end |
#subscribe(&proc) ⇒ Object
116 117 118 119 120 |
# File 'lib/redis_store.rb', line 116 def subscribe &proc @redis.subscribe @channel do |on| on. &proc end end |
#to_s ⇒ Object
130 131 132 |
# File 'lib/redis_store.rb', line 130 def to_s @channel end |