Skip to content

Instantly share code, notes, and snippets.

@mloughran
Created September 14, 2011 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mloughran/1216709 to your computer and use it in GitHub Desktop.
Save mloughran/1216709 to your computer and use it in GitHub Desktop.
em-hiredis watch-multi-exec example
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