# redis_clear.py 用于清理因单站点任务运行结束而产生的废弃 Redis 队列，通过服务器上的 crontab 服务定期启动
from redisbloom.client import Client
import re

redis_client = Client(host='107.182.191.3', port=7379, password='jlkj-841-2-redis')
pattern = "WebSite_\w+(\.\w+)+_\w{8}\-\w{4}\-\w{4}\-\w{4}\-\w{12}:\w+"

keys = redis_client.keys()
for key in keys:
    key_str = key.decode()
    if re.match(pattern, key_str):
        redis_client.delete(key)
        print(key_str)
