add check ads redis

This commit is contained in:
root 2019-09-10 13:57:32 +08:00
parent 9b239e42e2
commit 7accb6d877
5 changed files with 59 additions and 0 deletions

35
check_redis.py Normal file
View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
from myredis.myredis import my_redis
def main():
# key = '1066'
# ad::2001::6001::1::1063 ad::{\d+}::{\d+}::{\d}::{\d+}
all_keys = my_redis.keys()
ads_list = []
if all_keys:
for item in all_keys:
if len(item.split("::")) > 3:
print(f"find item = {item}! ")
try:
for one in my_redis.smembers(item):
ads_list.append(one)
except Exception:
print(f"{all_keys} get from redis via 'ad::[1004|2001]*' ")
else:
raise Exception("redis is nothing!")
print(f"redis ad list ={ads_list}")
for ad in ads_list:
name = f"ad::{ad}::info"
temp_data = my_redis.hgetall(name)
if temp_data:
pass
#print(temp_data)
else:
print(f"{name} ]\tnot found!")
if __name__ == "__main__":
main()

24
print_redis.py Normal file
View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from myredis.myredis import my_redis
def main():
key = '1066'
all_keys = my_redis.keys(pattern=f'*::{key}')
ads_list = []
if all_keys:
for item in all_keys:
try:
for one in my_redis.smembers(item):
ads_list.append(one)
except Exception:
print(f"{all_keys} get from redis via '*::{key}' ")
for ad in ads_list:
name = f"ad::{ad}::info"
temp_data = my_redis.hgetall(name)
print(temp_data)
if __name__ == "__main__":
main()