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
2edb98a8
Commit
2edb98a8
authored
3 years ago
by
宋柯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis清理
parent
3d5b4fc3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
get_redis_keys_hash.py
test/get_redis_keys_hash.py
+4
-3
No files found.
test/get_redis_keys_hash.py
View file @
2edb98a8
...
@@ -254,7 +254,7 @@ nodes=['7877da182171e313bc9326729f82999d1b629c79'
...
@@ -254,7 +254,7 @@ 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
=
[
''
]
search_keys
=
[
'
strategy:city_tag_id:device_id:
'
]
# conn2 = getRedisConn2()
# conn2 = getRedisConn2()
for
search_key
in
search_keys
:
for
search_key
in
search_keys
:
search_key
=
search_key
+
'*'
search_key
=
search_key
+
'*'
...
@@ -271,12 +271,13 @@ for search_key in search_keys:
...
@@ -271,12 +271,13 @@ for search_key in search_keys:
node_del_key_list
=
[]
node_del_key_list
=
[]
while
True
:
while
True
:
cursor
,
keys
=
conn
.
execute_command
(
"scan {} match {} count {} {}"
.
format
(
cursor
,
search_key
,
10000
,
node
))
cursor
,
keys
=
conn
.
execute_command
(
"scan {} match {} count {} {}"
.
format
(
cursor
,
search_key
,
10000
,
node
))
keys
=
list
(
map
(
lambda
key
:
str
(
key
,
encoding
=
'utf-8'
),
keys
))
node_key_count
+=
len
(
keys
)
node_key_count
+=
len
(
keys
)
cursor
=
str
(
cursor
,
encoding
=
'utf-8'
)
cursor
=
str
(
cursor
,
encoding
=
'utf-8'
)
pipline
=
conn
.
pipeline
()
pipline
=
conn
.
pipeline
()
for
key
in
keys
:
for
key
in
keys
:
key
=
str
(
key
,
encoding
=
'utf-8'
)
pipline
.
object
(
'idletime'
,
key
)
pipline
.
object
(
'idletime'
,
key
)
idletime_list
=
pipline
.
execute
()
idletime_list
=
pipline
.
execute
()
...
@@ -287,7 +288,7 @@ for search_key in search_keys:
...
@@ -287,7 +288,7 @@ for search_key in search_keys:
if
cursor
==
"0"
:
if
cursor
==
"0"
:
break
break
print
(
"node: {}, cursor: {}, node_key_count: {}, node_del_key_count: {}
"
.
format
(
node
,
cursor
,
node_key_count
,
len
(
node_del_key_list
)
))
print
(
"node: {}, cursor: {}, node_key_count: {}, node_del_key_count: {}
, node_del_key_rate: {}
%
"
.
format
(
node
,
cursor
,
node_key_count
,
len
(
node_del_key_list
),
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
)))
print
(
""
)
print
(
""
)
#
#
...
...
This diff is collapsed.
Click to expand it.
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