Created
June 29, 2012 02:26
-
-
Save yankov/3015276 to your computer and use it in GitHub Desktop.
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-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