Skip to content

Instantly share code, notes, and snippets.

@ponkotuy
Last active February 6, 2019 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ponkotuy/c97e4ce55c27ad107f79305509e11d15 to your computer and use it in GitHub Desktop.
Save ponkotuy/c97e4ce55c27ad107f79305509e11d15 to your computer and use it in GitHub Desktop.
DELETE Reids KEYS
#!/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