Commit c60f8d15 authored by 宋柯's avatar 宋柯

redis清理

parent 860d8495
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
# conn = redis.Redis(connection_pool=pool) # conn = redis.Redis(connection_pool=pool)
# return conn # return conn
# #
# def getRedisConn4(): def getRedisConn4():
# # startup_nodes = [ # startup_nodes = [
# # {'host': '172.16.179.131', 'port': '7000'}, # {'host': '172.16.179.131', 'port': '7000'},
# # ] # ]
# # conn = StrictRedisCluster(host="172.16.50.145",password="XfkMCCdWDIU%ls$h",port=6379,decode_responses=True) # conn = StrictRedisCluster(host="172.16.50.145",password="XfkMCCdWDIU%ls$h",port=6379,decode_responses=True)
# pool = redis.ConnectionPool(host="172.16.50.145",password="XfkMCCdWDIU%ls$h",port=6379,db=0) pool = redis.ConnectionPool(host="172.16.50.145",password="XfkMCCdWDIU%ls$h",port=6379,db=0)
# conn = redis.Redis(connection_pool=pool) conn = redis.Redis(connection_pool=pool)
# return conn return conn
# #
# def getRedisConn5(): # def getRedisConn5():
# pool = redis.ConnectionPool(host="172.16.50.159",password="XfkMCCdWDIU%ls$h3",port=6379,db=0) # pool = redis.ConnectionPool(host="172.16.50.159",password="XfkMCCdWDIU%ls$h3",port=6379,db=0)
...@@ -244,49 +244,52 @@ ...@@ -244,49 +244,52 @@
# #
# #
# def redis4(): # def redis4():
# nodes=['7877da182171e313bc9326729f82999d1b629c79' nodes=['7877da182171e313bc9326729f82999d1b629c79'
# ,'a4d4034faa81b935c2fd583053105b37f1c92ff1' ,'a4d4034faa81b935c2fd583053105b37f1c92ff1'
# ,'a8835d4c987847302bac66c5fc17ee1faae91fa3' ,'a8835d4c987847302bac66c5fc17ee1faae91fa3'
# ,'5a48236679f22637508651530633c9cc2f56f489' ,'5a48236679f22637508651530633c9cc2f56f489'
# ,'fc3715919081c2cf3b30a2f8defb055c03564fdc' ,'fc3715919081c2cf3b30a2f8defb055c03564fdc'
# ,'eec89d7480980749c998add484e80f23fe5022a4' ,'eec89d7480980749c998add484e80f23fe5022a4'
# ,'f3f1ec6df458a5093c31663517a3cadaed5ab29c' ,'f3f1ec6df458a5093c31663517a3cadaed5ab29c'
# ,'d35c630aad0a8b7f579bf4100f2860401b5d4f52'] ,'d35c630aad0a8b7f579bf4100f2860401b5d4f52']
# keys = ['rims:tag_v3:coldstart:','doris:tag_v3:coldstart:'] # keys = ['rims:tag_v3:coldstart:','doris:tag_v3:coldstart:']
keys = ['']
# conn2 = getRedisConn2() # conn2 = getRedisConn2()
# for key_k in keys: for key_k in keys:
# key = key_k + '*' key = key_k + '*'
# sum = 0 sum = 0
# key_sum = 0 key_sum = 0
# conn = getRedisConn4() conn = getRedisConn4()
# # pipline = conn.pipeline() # pipline = conn.pipeline()
# # key = "have_reply_answer_comment*" #139285 # key = "have_reply_answer_comment*" #139285
# # key = "device_register_qa_read_set:869574031646601*" #139285 # key = "device_register_qa_read_set:869574031646601*" #139285
# # key = "doris_feed:*" #139285 # key = "doris_feed:*" #139285
# for node in nodes: for node in nodes:
# cursor = "0" cursor = "0"
# while True: while True:
# del_datas = set() del_datas = set()
# cursor, data = conn.execute_command("scan {} match {} count {} {}".format(cursor,key,10000,node)) cursor, data = conn.execute_command("scan {} match {} count {} {}".format(cursor,key,100,node))
# cursor = str(cursor,encoding='utf-8') cursor = str(cursor,encoding='utf-8')
# for d in data: for d in data:
# dd = str(d, encoding='utf-8') dd = str(d, encoding='utf-8')
# if len(dd) > 0 and dd.startswith(key_k): print(dd)
# del_datas.add(str(d, encoding='utf-8')) # if len(dd) > 0 and dd.startswith(key_k):
# # pipline = conn.pipeline() # del_datas.add(str(d, encoding='utf-8'))
# for d in del_datas: sum += len(data)
# ls = [str(s,encoding='utf-8') for s in conn2.lrange(d,0,-1)] key_sum += len(del_datas)
# conn.lpush(d,ls) print(node,cursor, len(data), sum)
# # conn.delete(d) break
# # # pipline.expire(d, 60 * 60 * 24 * 3) # pipline = conn.pipeline()
# # pipline.execute() # for d in del_datas:
# sum += len(data) # ls = [str(s,encoding='utf-8') for s in conn2.lrange(d,0,-1)]
# key_sum += len(del_datas) # conn.lpush(d,ls)
# print(node,cursor, len(data), sum) # conn.delete(d)
# # if cursor == 0 or len(data) == 0: # # pipline.expire(d, 60 * 60 * 24 * 3)
# if cursor == "0": # pipline.execute()
# break # if cursor == 0 or len(data) == 0:
# print(key,key_sum) if cursor == "0":
break
print(key,key_sum)
# #
# nodes = ['7877da182171e313bc9326729f82999d1b629c79' # nodes = ['7877da182171e313bc9326729f82999d1b629c79'
# , 'a4d4034faa81b935c2fd583053105b37f1c92ff1' # , 'a4d4034faa81b935c2fd583053105b37f1c92ff1'
......
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