Last active
July 29, 2016 09:24
-
-
Save wangchen/54108e3b86bd3d191738a33e8c27ee14 to your computer and use it in GitHub Desktop.
Print size of all redis keys
This file contains hidden or 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
import redis | |
r = redis.Redis() | |
i = 0 | |
chunk_size = 1000 | |
while True: | |
i, keys = r.scan(i, count=chunk_size) | |
if i == 0: | |
break | |
pipeline = r.pipeline() | |
for key in keys: | |
pipeline.debug_object(key) | |
vals = pipeline.execute() | |
for k, v in zip(keys, vals): | |
print("%s\t%s" % (k.decode(), v['serializedlength'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment