Created
October 19, 2015 15:16
-
-
Save 72squared/c0611dc573664d06e68f to your computer and use it in GitHub Desktop.
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": 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