Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
serviceRec
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郭羽
serviceRec
Commits
c60f8d15
Commit
c60f8d15
authored
Dec 03, 2021
by
宋柯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis清理
parent
860d8495
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
49 deletions
+52
-49
get_redis_keys_hash.py
test/get_redis_keys_hash.py
+52
-49
No files found.
test/get_redis_keys_hash.py
View file @
c60f8d15
...
...
@@ -24,14 +24,14 @@
# conn = redis.Redis(connection_pool=pool)
# return conn
#
#
def getRedisConn4():
#
# startup_nodes = [
#
# {'host': '172.16.179.131', 'port': '7000'},
#
# ]
#
# 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)
#
conn = redis.Redis(connection_pool=pool)
#
return conn
def
getRedisConn4
():
# startup_nodes = [
# {'host': '172.16.179.131', 'port': '7000'},
# ]
# 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
)
conn
=
redis
.
Redis
(
connection_pool
=
pool
)
return
conn
#
# def getRedisConn5():
# pool = redis.ConnectionPool(host="172.16.50.159",password="XfkMCCdWDIU%ls$h3",port=6379,db=0)
...
...
@@ -244,49 +244,52 @@
#
#
# def redis4():
#
nodes=['7877da182171e313bc9326729f82999d1b629c79'
#
,'a4d4034faa81b935c2fd583053105b37f1c92ff1'
#
,'a8835d4c987847302bac66c5fc17ee1faae91fa3'
#
,'5a48236679f22637508651530633c9cc2f56f489'
#
,'fc3715919081c2cf3b30a2f8defb055c03564fdc'
#
,'eec89d7480980749c998add484e80f23fe5022a4'
#
,'f3f1ec6df458a5093c31663517a3cadaed5ab29c'
#
,'d35c630aad0a8b7f579bf4100f2860401b5d4f52']
nodes
=
[
'7877da182171e313bc9326729f82999d1b629c79'
,
'a4d4034faa81b935c2fd583053105b37f1c92ff1'
,
'a8835d4c987847302bac66c5fc17ee1faae91fa3'
,
'5a48236679f22637508651530633c9cc2f56f489'
,
'fc3715919081c2cf3b30a2f8defb055c03564fdc'
,
'eec89d7480980749c998add484e80f23fe5022a4'
,
'f3f1ec6df458a5093c31663517a3cadaed5ab29c'
,
'd35c630aad0a8b7f579bf4100f2860401b5d4f52'
]
# keys = ['rims:tag_v3:coldstart:','doris:tag_v3:coldstart:']
keys
=
[
''
]
# conn2 = getRedisConn2()
# for key_k in keys:
# key = key_k + '*'
# sum = 0
# key_sum = 0
# conn = getRedisConn4()
# # pipline = conn.pipeline()
# # key = "have_reply_answer_comment*" #139285
# # key = "device_register_qa_read_set:869574031646601*" #139285
# # key = "doris_feed:*" #139285
# for node in nodes:
# cursor = "0"
# while True:
# del_datas = set()
# cursor, data = conn.execute_command("scan {} match {} count {} {}".format(cursor,key,10000,node))
# cursor = str(cursor,encoding='utf-8')
# for d in data:
# dd = str(d, encoding='utf-8')
# if len(dd) > 0 and dd.startswith(key_k):
# del_datas.add(str(d, encoding='utf-8'))
# # pipline = conn.pipeline()
# for d in del_datas:
# ls = [str(s,encoding='utf-8') for s in conn2.lrange(d,0,-1)]
# conn.lpush(d,ls)
# # conn.delete(d)
# # # pipline.expire(d, 60 * 60 * 24 * 3)
# # pipline.execute()
# sum += len(data)
# key_sum += len(del_datas)
# print(node,cursor, len(data), sum)
# # if cursor == 0 or len(data) == 0:
# if cursor == "0":
# break
# print(key,key_sum)
for
key_k
in
keys
:
key
=
key_k
+
'*'
sum
=
0
key_sum
=
0
conn
=
getRedisConn4
()
# pipline = conn.pipeline()
# key = "have_reply_answer_comment*" #139285
# key = "device_register_qa_read_set:869574031646601*" #139285
# key = "doris_feed:*" #139285
for
node
in
nodes
:
cursor
=
"0"
while
True
:
del_datas
=
set
()
cursor
,
data
=
conn
.
execute_command
(
"scan {} match {} count {} {}"
.
format
(
cursor
,
key
,
100
,
node
))
cursor
=
str
(
cursor
,
encoding
=
'utf-8'
)
for
d
in
data
:
dd
=
str
(
d
,
encoding
=
'utf-8'
)
print
(
dd
)
# if len(dd) > 0 and dd.startswith(key_k):
# del_datas.add(str(d, encoding='utf-8'))
sum
+=
len
(
data
)
key_sum
+=
len
(
del_datas
)
print
(
node
,
cursor
,
len
(
data
),
sum
)
break
# pipline = conn.pipeline()
# for d in del_datas:
# ls = [str(s,encoding='utf-8') for s in conn2.lrange(d,0,-1)]
# conn.lpush(d,ls)
# conn.delete(d)
# # pipline.expire(d, 60 * 60 * 24 * 3)
# pipline.execute()
# if cursor == 0 or len(data) == 0:
if
cursor
==
"0"
:
break
print
(
key
,
key_sum
)
#
# nodes = ['7877da182171e313bc9326729f82999d1b629c79'
# , 'a4d4034faa81b935c2fd583053105b37f1c92ff1'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment