python 模糊删除redis的keys
def delete_redis_keys_by_match(match, count=20):
"""
redis模糊删除
:param match: 正则匹配规则
:param count: 每次查找数量
:return: 删除的个数
"""
cursor = 0
flag = True
keys_lists = []
while cursor > 0 or flag:
cursor, keys = redis_store.scan(cursor, match, count)
keys_lists.extend(keys)
flag = False
keys_lists = [key.decode() for key in keys_lists]
redis_store.delete(*keys_lists)
return len(keys_lists)