Skip to content

Instantly share code, notes, and snippets.

@milyenpabo
Created October 8, 2015 11:21
Show Gist options
  • Save milyenpabo/f2d0b48632276958cce8 to your computer and use it in GitHub Desktop.
Save milyenpabo/f2d0b48632276958cce8 to your computer and use it in GitHub Desktop.
Script to write a redis cluster
from rediscluster import RedisCluster
startup_nodes = [{"host": "127.0.0.1", "port": "27002"}]
r = RedisCluster(startup_nodes=startup_nodes, max_connections=32, decode_responses=True)
N = 1000000
p = 0
pdiff = 1
print "Writing %d keys to redis" % N
for i in xrange(N):
d = str(i)
r.set(d, d)
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