1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import redis
# 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 diary_key():
r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN6@172.16.40.133:6379')
cursor = 0
while True:
new_cursor,keys_list = r.scan(cursor,"TS:recommend_tractate_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
def qa_key():
r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN6@172.16.40.133:6379')
cursor = 0
while True:
new_cursor,keys_list = r.scan(cursor,"TS:recommend_answer_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(keys_list))
print("删除帖子数量")
print(len(delete_keys))
# 循环一遍后结束
if new_cursor == 0:
break
cursor = new_cursor
def topic_key():
r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN6@172.16.40.133:6379')
cursor = 0
while True:
new_cursor,keys_list = r.scan(cursor,"TS:recommend_answer_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(keys_list))
print("删除帖子数量")
print(len(delete_keys))
# 循环一遍后结束
if new_cursor == 0:
break
cursor = new_cursor
def search():
r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN9@172.16.40.173:6379')
cursor = 0
while True:
new_cursor,keys_list = r.scan(cursor,"device:latest:action:tag:names:update:flag*",2000)
if len(keys_list) > 0:
print(len(keys_list))
r.delete(*keys_list)
# 循环一遍后结束
if new_cursor == 0:
break
cursor = new_cursor
def find():
r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN9@172.16.40.173:6379')
cursor = 0
while True:
new_cursor,keys_list = r.scan(cursor,"cold_topic:device_id:*",2000)
if len(keys_list) > 0:
print(len(keys_list))
print(keys_list)
# 循环一遍后结束
if new_cursor == 0:
break
cursor = new_cursor
if __name__ == "__main__":
search()