Commit d3dfa7f8 authored by 宋柯's avatar 宋柯

redis清理

parent 839dd33d
...@@ -266,20 +266,23 @@ for search_key in search_keys: ...@@ -266,20 +266,23 @@ for search_key in search_keys:
# key = "doris_feed:*" #139285 # key = "doris_feed:*" #139285
for node in nodes: for node in nodes:
cursor = "0" cursor = "0"
node_key_count = 0
node_del_key_set = set()
while True: while True:
del_datas = set()
cursor, keys = conn.execute_command("scan {} match {} count {} {}".format(cursor,search_key,10,node)) cursor, keys = conn.execute_command("scan {} match {} count {} {}".format(cursor,search_key,10,node))
node_key_count += len(keys)
cursor = str(cursor,encoding='utf-8') cursor = str(cursor,encoding='utf-8')
for key in keys: for key in keys:
key = str(key, encoding='utf-8') key = str(key, encoding='utf-8')
idletime = conn.object('idletime', key) idletime = conn.object('idletime', key)
if idletime > 2592000: if idletime > 2592000:
print("key:{},idletime:{}".format(key,idletime)) # print("key:{},idletime:{}".format(key,idletime))
node_del_key_set.add(key)
# if len(dd) > 0 and dd.startswith(key_k): # if len(dd) > 0 and dd.startswith(key_k):
# del_datas.add(str(d, encoding='utf-8')) # del_datas.add(str(d, encoding='utf-8'))
sum += len(keys)
key_sum += len(del_datas) # key_sum += len(del_datas)
break # break
# pipline = conn.pipeline() # pipline = conn.pipeline()
# for d in del_datas: # for d in del_datas:
# ls = [str(s,encoding='utf-8') for s in conn2.lrange(d,0,-1)] # ls = [str(s,encoding='utf-8') for s in conn2.lrange(d,0,-1)]
...@@ -290,7 +293,7 @@ for search_key in search_keys: ...@@ -290,7 +293,7 @@ for search_key in search_keys:
# if cursor == 0 or len(data) == 0: # if cursor == 0 or len(data) == 0:
if cursor == "0": if cursor == "0":
break break
print("node:{},cursor:{},len(keys):{},sum:{}".format(node,cursor, len(keys), sum)) print("node: {}, cursor: {}, node_key_count: {}, node_del_key_count: {}".format(node, cursor, node_key_count, len(node_del_key_set)))
print("") print("")
# #
# nodes = ['7877da182171e313bc9326729f82999d1b629c79' # nodes = ['7877da182171e313bc9326729f82999d1b629c79'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment