Skip to content

Instantly share code, notes, and snippets.

@yankov
Created June 29, 2012 02:26
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 yankov/3015276 to your computer and use it in GitHub Desktop.
Save yankov/3015276 to your computer and use it in GitHub Desktop.
require 'em-synchrony'
require 'redis'
require 'redis/distributed'
require 'digest'
require 'redis/connection/synchrony'
EM.synchrony do
# this one fast
redis_hosts = ["redis://localhost:6379/1", "redis://localhost:6378/1"]
# this one slow
# redis_hosts = ["redis://redis-host1.com:6379/1", "redis://redis-host2.com:6379/1"]
r = Redis::Distributed.new(redis_hosts)
1000.times do |k|
key = ::Digest::MD5.hexdigest("f" + k.to_s)
100.times do |x|
r.sadd(key, ::Digest::MD5.hexdigest("f" + x.to_s)) {}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment