Skip to content

Instantly share code, notes, and snippets.

@72squared
Created October 19, 2015 15:16
Show Gist options
  • Save 72squared/c0611dc573664d06e68f to your computer and use it in GitHub Desktop.
Save 72squared/c0611dc573664d06e68f to your computer and use it in GitHub Desktop.
from rediscluster import RedisCluster
startup_nodes = [{"host": "127.0.0.1", "port": 7000}]
r = RedisCluster(startup_nodes=startup_nodes, max_connections=32, decode_responses=True)
N = 1000000
p = 0
pdiff = 1
progress = 0
print "Writing %d keys to redis" % N
for i in xrange(N):
d = str(i)
r.set(d, d)
pipe = r.pipeline(transaction=False)
pipe.incrby(d, 1)
pipe.incrby(d, 2)
pipe.execute()
progress = 100.0*i/N
if progress >= p:
print "%.0f%%" % progress,
p += pdiff
if progress < 100:
print "100%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment