Created
April 1, 2014 16:31
-
-
Save steinnes/9917764 to your computer and use it in GitHub Desktop.
Because "keys *" can block for several seconds (or longer) on large redis instances, this script scans through keys and dumps them safely. Suffers from the standard SCAN limitations, so it actually may never finish.
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
import redis | |
import sys | |
port = None | |
try: | |
port = int(sys.argv[2]) | |
except: | |
pass | |
r = redis.Redis(sys.argv[1], port) | |
cursor = "0" | |
while True: | |
cursor, keys = r.scan(cursor) | |
for k in keys: | |
print k | |
if cursor == "0": | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment