Last active
February 6, 2019 16:17
-
-
Save ponkotuy/c97e4ce55c27ad107f79305509e11d15 to your computer and use it in GitHub Desktop.
DELETE Reids 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
#!/usr/bin/env python3 | |
# -*- coding:utf-8 -*- | |
import sys | |
import redis | |
HOST_NAME = "" | |
DB_NUMBER = 0 | |
if __name__ == "__main__": | |
args = sys.argv | |
conn = redis.StrictRedis(host=HOST_NAME, db=DB_NUMBER) | |
xs = [] | |
for idx, key in enumerate(conn.scan_iter(match=args[1], count=1000)): | |
xs.append(key) | |
if idx % 100 == 0: | |
conn.delete(*xs) | |
print(f"{idx}:{key}") | |
xs.clear() | |
conn.delete(*xs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment