from redis import StrictRedis
import redis
def redis_operator(userId):
# StrictRedis的连接池的实现方式
pool = redis.ConnectionPool(host=host, port=6379,db=0, password=None)
r = StrictRedis(connection_pool=pool)
# 查询关键字的所有key
key_list = r.keys(str(userId)+'*')
# print(key_list)
for i in key_list:
i=i.decode("utf-8")
if i=="{}:account".format(userId):
dict_key=r.hgetall(i)
for k,v in dict_key.items():
if k==b'access_token' or k==b'refresh_token':
key_list.append(v)
print(key_list)
for key in key_list[:]:
r.delete(key)