Skip to content

Instantly share code, notes, and snippets.

@HeartSaVioR
Created June 12, 2015 08:42
Show Gist options
  • Save HeartSaVioR/924d3a3fa90ebee73a2c to your computer and use it in GitHub Desktop.
Save HeartSaVioR/924d3a3fa90ebee73a2c to your computer and use it in GitHub Desktop.
proto.rb
def gen_redis_proto(*cmd)
proto = ""
proto << "*"+cmd.length.to_s+"\r\n"
cmd.each{|arg|
proto << "$"+arg.to_s.bytesize.to_s+"\r\n"
proto << arg.to_s+"\r\n"
}
proto
end
(0...1000).each{|n|
STDOUT.write(gen_redis_proto("SET","Key#{n}","Value#{n}"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment