Created
January 12, 2018 11:11
-
-
Save tmpbook/a6ec4a023c1224cc97f702ed9e12a8d5 to your computer and use it in GitHub Desktop.
scan redis by python.
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 | |
pool=redis.ConnectionPool(host='redis_hostname', port=6379, max_connections=100) | |
r = redis.StrictRedis(connection_pool=pool) | |
cursor_number, keys = r.execute_command('scan', 0, "count", 200000) | |
while True: | |
if cursor_number == 0: | |
# 结束一次完整的比遍历 | |
break | |
cursor_number, keys = r.execute_command('scan', cursor_number, "count", 200000) | |
# do something with keys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment