Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
16322a92
Commit
16322a92
authored
Sep 30, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change
parent
11d21648
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
34 deletions
+52
-34
monitor.py
monitor.py
+52
-34
No files found.
monitor.py
View file @
16322a92
import
redis
def
delete_key
():
# def delete_key():
# r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN6@172.16.40.133:6379')
# keys = r.keys("TS:recommend_diary_set:device_id:*")
# sum = 0
# print("diary")
# print(len(keys))
# for i in keys:
# if r.ttl(i) == -1:
# sum = sum +1
# r.delete(i)
# if sum % 1000 == 0:
# print(sum)
#
# sum = 0
# keys = r.keys("TS:recommend_tractate_set:device_id:*")
# print("teizi")
# print(len(keys))
# for i in keys:
# if r.ttl(i) == -1:
# r.delete(i)
# sum = sum + 1
# if sum % 1000 == 0:
# print(sum)
#
# sum = 0
# print("qa")
# print(len(keys))
# keys = r.keys("TS:recommend_answer_set:device_id:*")
# for i in keys:
# if r.ttl(i) == -1:
# r.delete(i)
# sum = sum + 1
# if sum % 1000 == 0:
# print(sum)
def
scan_key
():
r
=
redis
.
StrictRedis
.
from_url
(
'redis://:ReDis!GmTx*0aN6@172.16.40.133:6379'
)
keys
=
r
.
keys
(
"TS:recommend_diary_set:device_id:*"
)
sum
=
0
print
(
"diary"
)
print
(
len
(
keys
))
for
i
in
keys
:
if
r
.
ttl
(
i
)
==
-
1
:
sum
=
sum
+
1
r
.
delete
(
i
)
if
sum
%
1000
==
0
:
print
(
sum
)
sum
=
0
keys
=
r
.
keys
(
"TS:recommend_tractate_set:device_id:*"
)
print
(
"teizi"
)
print
(
len
(
keys
))
for
i
in
keys
:
if
r
.
ttl
(
i
)
==
-
1
:
r
.
delete
(
i
)
sum
=
sum
+
1
if
sum
%
1000
==
0
:
print
(
sum
)
sum
=
0
print
(
"qa"
)
print
(
len
(
keys
))
keys
=
r
.
keys
(
"TS:recommend_answer_set:device_id:*"
)
for
i
in
keys
:
if
r
.
ttl
(
i
)
==
-
1
:
r
.
delete
(
i
)
sum
=
sum
+
1
if
sum
%
1000
==
0
:
print
(
sum
)
cursor
=
0
while
True
:
new_cursor
,
keys_list
=
r
.
scan
(
cursor
,
"TS:recommend_diary_set:device_id:*"
,
2000
)
delete_keys
=
[]
for
i
in
keys_list
:
if
r
.
ttl
(
i
)
==
-
1
:
delete_keys
.
append
(
i
)
if
len
(
delete_keys
)
>
0
:
r
.
delete
(
*
delete_keys
)
print
(
"删除日记数量"
)
print
(
len
(
delete_keys
))
# 循环一遍后结束
if
new_cursor
==
0
:
break
cursor
=
new_cursor
if
__name__
==
"__main__"
:
delete
_key
()
scan
_key
()
...
...
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