Skip to content

Instantly share code, notes, and snippets.

@agrison agrison/
Last active Aug 29, 2015

What would you like to do?
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
You can’t perform that action at this time.