Created
September 14, 2011 14:27
-
-
Save mloughran/1216709 to your computer and use it in GitHub Desktop.
em-hiredis watch-multi-exec example
This file contains hidden or 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 'em-hiredis' | |
EM.run { | |
redis = EM::Hiredis.connect | |
redis.set('foo', 'value') | |
redis.watch('foo') { | |
puts "Watching - try changing key foo within 1s" | |
EM.add_timer(1) { | |
redis.multi | |
redis.get('foo') | |
df = redis.exec | |
df.callback { |get_result| | |
if get_result | |
p [:foo, get_result] | |
else | |
puts "Multi/exec failed" | |
end | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment