fix some error

This commit is contained in:
pengtao 2019-07-15 16:21:07 +08:00
parent 1520889b20
commit 43ecffc2d9

View File

@ -35,7 +35,7 @@ def send_cache_data():
item = {}
try:
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item['ad_url'], \
item['ad_sort'], item['companyid'], item['locationid'], item['gameid'] = line
item['ad_sort'], item['companyid'], item['locationid'], item['gameid'] = line
all.append(item)
except Exception:
log.error("split data failed", exc_info=True)
@ -50,7 +50,7 @@ def send_cache_data():
item = {}
try:
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item['ad_url'], \
item['ad_sort'], item['companyid'], item['locationid'], item['gameid'] = line
item['ad_sort'], item['companyid'], item['locationid'], item['gameid'] = line
all.append(item)
except Exception:
log.error("split data failed", exc_info=True)
@ -60,7 +60,10 @@ def send_cache_data():
key = f"{line.get('gameid', 0)}::{line.get('locationid', 0)}"
if my_redis.exists(key):
# 检查num是否已达到设定数值
num = my_redis.get(f"{key}:num") or 0
num = my_redis.get(f"{key}:num")
if not num:
num=0
print("num was ",num)
if line['num'] != -1 and line['num'] <= num:
# 该广告已播放达到次数,从缓存中清除
my_redis.srem(key, line['id'])