Commit 79d36353 authored by 宋柯's avatar 宋柯

redis清理

parent 4ad15b63
...@@ -254,7 +254,8 @@ nodes=['7877da182171e313bc9326729f82999d1b629c79' ...@@ -254,7 +254,8 @@ nodes=['7877da182171e313bc9326729f82999d1b629c79'
,'f3f1ec6df458a5093c31663517a3cadaed5ab29c' ,'f3f1ec6df458a5093c31663517a3cadaed5ab29c'
,'d35c630aad0a8b7f579bf4100f2860401b5d4f52'] ,'d35c630aad0a8b7f579bf4100f2860401b5d4f52']
# keys = ['rims:tag_v3:coldstart:','doris:tag_v3:coldstart:'] # keys = ['rims:tag_v3:coldstart:','doris:tag_v3:coldstart:']
search_keys = ['strategy:city_tag_id:device_id:'] search_keys = ['']
do_delete = False
# conn2 = getRedisConn2() # conn2 = getRedisConn2()
for search_key in search_keys: for search_key in search_keys:
search_key = search_key + '*' search_key = search_key + '*'
...@@ -292,18 +293,19 @@ for search_key in search_keys: ...@@ -292,18 +293,19 @@ for search_key in search_keys:
print("node: {}, cursor: {}, node_key_count: {}, node_del_key_count: {}, node_del_key_rate: {}%".format(node, cursor, node_key_count, node_del_key_count, 100 * len(node_del_key_list) / node_key_count)) print("node: {}, cursor: {}, node_key_count: {}, node_del_key_count: {}, node_del_key_rate: {}%".format(node, cursor, node_key_count, node_del_key_count, 100 * len(node_del_key_list) / node_key_count))
print("node: {}, node_del_key_sample_100: {}".format(node, np.random.choice(node_del_key_list, 50, replace= False))) print("node: {}, node_del_key_sample_100: {}".format(node, np.random.choice(node_del_key_list, 50, replace= False)))
node_del_batch_size = 10000 if do_delete:
node_has_del_key_count = 0 node_del_batch_size = 10000
for batch_start_idx in range(0,node_del_key_count, node_del_batch_size): node_has_del_key_count = 0
node_del_key_batch_list = node_del_key_list[batch_start_idx : batch_start_idx + node_del_batch_size] for batch_start_idx in range(0,node_del_key_count, node_del_batch_size):
pipline = conn.pipeline() node_del_key_batch_list = node_del_key_list[batch_start_idx : batch_start_idx + node_del_batch_size]
for node_del_key in node_del_key_batch_list: pipline = conn.pipeline()
pipline.delete(node_del_key) for node_del_key in node_del_key_batch_list:
# pass pipline.delete(node_del_key)
pipline.execute() # pass
node_has_del_key_count += len(node_del_key_batch_list) pipline.execute()
print("node: {}, node_has_del_key_count: {}, node_del_key_count: {}, node_has_del_key_rate: {}%".format(node, node_has_del_key_count, node_del_key_count, 100 * node_has_del_key_count / node_del_key_count)) node_has_del_key_count += len(node_del_key_batch_list)
print("node: {}, node_has_del_key_batch_sample_50: {}".format(node, np.random.choice(node_del_key_batch_list, 50, replace= False))) print("node: {}, node_has_del_key_count: {}, node_del_key_count: {}, node_has_del_key_rate: {}%".format(node, node_has_del_key_count, node_del_key_count, 100 * node_has_del_key_count / node_del_key_count))
print("node: {}, node_has_del_key_batch_sample_50: {}".format(node, np.random.choice(node_del_key_batch_list, 50, replace= False)))
print("") print("")
# #
......
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