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
3d5b4fc3
Commit
3d5b4fc3
authored
3 years ago
by
宋柯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis清理
parent
d01bb7f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
9 deletions
+4
-9
get_redis_keys_hash.py
test/get_redis_keys_hash.py
+4
-9
No files found.
test/get_redis_keys_hash.py
View file @
3d5b4fc3
...
...
@@ -3,6 +3,7 @@ import json
import
time
import
pymysql
from
rediscluster
import
StrictRedisCluster
import
numpy
as
np
# def getRedisConn():
# conn = redis.Redis(host="172.18.51.10", port=6379,db=0)
# conn.execute_command()
...
...
@@ -269,31 +270,25 @@ for search_key in search_keys:
node_key_count
=
0
node_del_key_list
=
[]
while
True
:
cursor
,
keys
=
conn
.
execute_command
(
"scan {} match {} count {} {}"
.
format
(
cursor
,
search_key
,
2
000
,
node
))
cursor
,
keys
=
conn
.
execute_command
(
"scan {} match {} count {} {}"
.
format
(
cursor
,
search_key
,
10
000
,
node
))
node_key_count
+=
len
(
keys
)
cursor
=
str
(
cursor
,
encoding
=
'utf-8'
)
pipline
=
conn
.
pipeline
()
for
key
in
keys
:
key
=
str
(
key
,
encoding
=
'utf-8'
)
pipline
.
object
(
'idletime'
,
key
)
# idletime = conn.object('idletime', key)
# if idletime > 2592000:
# node_del_key_set.add(key)
idletime_list
=
pipline
.
execute
()
for
idx
,
idletime
in
enumerate
(
idletime_list
):
if
idletime
>
2592000
:
node_del_key_list
.
append
(
keys
[
idx
])
# print("idletime_list:{}".format(idletime_list))
# break
if
cursor
==
"0"
:
break
print
(
"node: {}, cursor: {}, node_key_count: {}, node_del_key_count: {}"
.
format
(
node
,
cursor
,
node_key_count
,
len
(
node_del_key_list
)))
print
(
"node: {}, node_del_key_sample_100: {}"
.
format
(
node
,
np
.
random
.
choice
(
node_del_key_list
,
50
,
replace
=
False
)))
print
(
""
)
#
# nodes = ['7877da182171e313bc9326729f82999d1b629c79'
...
...
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