Skip to content

Instantly share code, notes, and snippets.

@agrison
Last active August 29, 2015 14:25
Show Gist options
  • Save agrison/37d55becc579b4d840fc to your computer and use it in GitHub Desktop.
Save agrison/37d55becc579b4d840fc to your computer and use it in GitHub Desktop.
Generate 1M redis SET commands using redis protocol
from __future__ import print_function
import uuid, sys
def redis_protocol(cmd):
proto = "*%d\r\n" % len(cmd.split(' '))
for arg in cmd.split(' '):
proto += "$%d\r\n%s\r\n" % (len(arg), arg)
return proto
sample = ""
for _ in xrange(1000000):
sample += redis_protocol("SET %s %s" % (uuid.uuid4(), uuid.uuid4()))
print(sample, file=open('sample2.input', 'w+'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment