Created
June 29, 2012 06:44
-
-
Save karlseguin/3016329 to your computer and use it in GitHub Desktop.
generating fake score data for testing different redis models
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 'digest' | |
require 'redis' | |
require 'json' | |
redis = Redis.new | |
$leaderboard_count = 5 | |
$scope_count = 3 | |
$user_count = 200000 | |
def username(i) | |
Digest::SHA1.hexdigest(i.to_s) | |
end | |
(1..$leaderboard_count).each do |lb| | |
redis.pipelined do | |
(1..$user_count).each do |i| | |
name = username(i) | |
data = {:points => i * lb}.to_json | |
redis.hset name, "#{lb}:1", data | |
redis.hset name, "#{lb}:2", data | |
redis.hset name, "#{lb}:3", data | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment