Skip to content

Instantly share code, notes, and snippets.

@vincentchu
Created May 10, 2011 00:39
Show Gist options
  • Save vincentchu/963724 to your computer and use it in GitHub Desktop.
Save vincentchu/963724 to your computer and use it in GitHub Desktop.
redis.rb
require 'rubygems'
require 'redis'
require 'redis/distributed'
redis = Redis::Distributed.new(['redis://localhost:6379', 'redis://localhost:6380'])
(1..10_000).each do |i|
key = "rand_#{rand}"
val = rand(1000)
puts "key = #{key}" if (i%1000 == 0)
redis.set(key, val)
end
counts = redis.dbsize
percent_diff = (counts[0] - counts[1])/counts[1].to_f
puts "counts = #{counts.inspect}"
puts "% diff = #{percent_diff}"
# counts = [64027, 75973]
# % diff = -0.157240072130889
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment