Skip to content

Instantly share code, notes, and snippets.

@tmpbook
Created January 12, 2018 11:11
Show Gist options
  • Save tmpbook/a6ec4a023c1224cc97f702ed9e12a8d5 to your computer and use it in GitHub Desktop.
Save tmpbook/a6ec4a023c1224cc97f702ed9e12a8d5 to your computer and use it in GitHub Desktop.
scan redis by python.
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