添加返回条数控制

This commit is contained in:
pengtao 2019-07-17 17:49:27 +08:00
parent edc10bcb95
commit fb0ef6cf7b

View File

@ -61,11 +61,11 @@ def send_cache_data():
# log.info(f"get data was {all}!\n")
for line in all:
key = f"ad::{line.get('gameid', 0)}::{line.get('locationid', 0)}"
if line['ad_num'] > 0:
if int(line['ad_num']) > 0:
num = my_redis.get(f"ad::{line['id']}::num")
if not num:
num = 0
if line['ad_num'] > num:
if int(line['ad_num']) > int(num):
my_redis.sadd(key, line['id'])
my_redis.expire(key, 120)
n = int(line['ad_num'] - num)
@ -73,7 +73,7 @@ def send_cache_data():
else:
my_redis.srem(key, line['id'])
log.info(f"remove {line['id']} from {key}!")
elif line['ad_num'] == 0:
elif int(line['ad_num']) == 0:
my_redis.sadd(key, line['id'])
my_redis.expire(key, 120)
log.info(f"add {line['id']} to {key} ,num was unlimit !")