Created
October 8, 2015 11:21
-
-
Save milyenpabo/f2d0b48632276958cce8 to your computer and use it in GitHub Desktop.
Script to write a redis cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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