Created
August 24, 2010 16:02
-
-
Save samflores/547798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "redis" | |
@redis = Redis.new(:timeout => 0) | |
@redis.subscribe('a', 'b') do |on| | |
on.subscribe do |klass, num_subs| | |
puts "Subscribed to #{klass} (#{num_subs} subscriptions)" | |
end | |
on.message do |klass, msg| | |
puts "#{klass} received: #{msg}" | |
if msg == 'exit' | |
@redis.unsubscribe | |
end | |
end | |
on.unsubscribe do |klass, num_subs| | |
puts "Unsubscribed from #{klass} (#{num_subs} subscriptions)" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment