From 39b9789d51ed41b5850adc814ec52a2ac01c7e62 Mon Sep 17 00:00:00 2001 From: pengtao Date: Wed, 17 Jul 2019 14:28:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BC=93=E5=AD=98=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 395bb92..73519ac 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -59,21 +59,25 @@ 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 my_redis.exists(key): + if line['ad_num'] > 0: num = my_redis.get(f"ad::{line['id']}::num") if not num: num = 0 - if line['ad_num'] == 0 or line['ad_num'] > num: + if line['ad_num'] > num: my_redis.sadd(key, line['id']) my_redis.expire(key, 120) - log.info(f"add {line['id']} to {key} !") - else: + log.info(f"add {line['id']} to {key} ,num was {line['ad_num']}!") + elif line['ad_num'] == 0: my_redis.sadd(key, line['id']) my_redis.expire(key, 120) - log.info(f"add {line['id']} to {key} !") + log.info(f"add {line['id']} to {key} ,num was unlimit !") + else: + log.error(f"get ad_num from mysql failed! ad_num={line['ad_num']}") + if not my_redis.exists(f"ad::{line['id']}::info"): my_redis.hmset(f"ad::{line['id']}::info", line) - my_redis.expire(f"ad::{line['id']}::info", 3600 * 24) + my_redis.expire(f"ad::{line['id']}::info", 3600 * 24 * 7) + log.info(f"add ad::{line['id']}::info to redis!") class DispatchHandler(tornado.web.RequestHandler):