From be0953c8371d68a99578182d240da885c8e8f288 Mon Sep 17 00:00:00 2001 From: pengtao Date: Tue, 16 Jul 2019 14:00:38 +0800 Subject: [PATCH] fix some error --- ad_interface_tornado.py | 14 +++++++------- config.py | 6 +++--- config_dev.py | 11 +++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 config_dev.py diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 7fbc391..cbb1e1f 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -52,23 +52,23 @@ def send_cache_data(): if all: log.info(f"get data was {all}!\n") for line in all: - key = f"{line.get('gameid', 0)}::{line.get('locationid', 0)}" + key = f"ad::{line.get('gameid', 0)}::{line.get('locationid', 0)}" if my_redis.exists(key): my_redis.sadd(key, line['id']) # 检查num是否已达到设定数值 - num = my_redis.get(f"{line['id']}::num") + num = my_redis.get(f"ad::{line['id']}::num") if not num: num = 0 if line['ad_num'] > 0 and line['ad_num'] <= num: # 该广告已播放达到次数,从缓存中清除 my_redis.srem(key, line['id']) # 清理广告详细记录 - my_redis.expire(f"{line['id']}::info", 0) + my_redis.expire(f"ad::{line['id']}::info", 0) else: my_redis.sadd(key, line['id']) - log.info(f"check {line['id']}::info") - if not my_redis.exists(f"{line['id']}::info"): - my_redis.hmset(f"{line['id']}::info", line) + log.info(f"check ad::{line['id']}::info") + if not my_redis.exists(f"ad::{line['id']}::info"): + my_redis.hmset(f"ad::{line['id']}::info", line) len_all = len(all) log.info(f"write {len_all} to cache!") @@ -83,7 +83,7 @@ def remove_expire_data(): for line in data: try: id, gameid, locationid = line - my_redis.srem(f"{gameid}::{locationid}", id) + my_redis.srem(f"ad::{gameid}::{locationid}", id) log.info(f"remove expire ad {id}!") except Exception: log.error("split data from db failed!", exc_info=True) diff --git a/config.py b/config.py index 827b702..1a0cecb 100644 --- a/config.py +++ b/config.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -redis_company_config = {'host': '192.168.100.20', 'port': 6379, 'db': 1} +redis_company_config = {'host': '10.10.4.8', 'port': 6379, 'db': 1,'passwd':'crs-9ltb97ds:i33dkxshh'} expire_time = 7200 -mysql_promotion_config = {'user': 'miles', 'pswd': 'aspect', 'host': '192.168.100.30', 'db': 'test'} -ad_list_interface_port=5555 +mysql_promotion_config = {'user': 'ad', 'pswd': 'config.py', 'host': '10.10.3.5', 'db': 'ad'} +ad_list_interface_port=5014 BEGIN = '1999-01-01' END = '3000-01-01' diff --git a/config_dev.py b/config_dev.py new file mode 100644 index 0000000..827b702 --- /dev/null +++ b/config_dev.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +redis_company_config = {'host': '192.168.100.20', 'port': 6379, 'db': 1} +expire_time = 7200 +mysql_promotion_config = {'user': 'miles', 'pswd': 'aspect', 'host': '192.168.100.30', 'db': 'test'} +ad_list_interface_port=5555 +BEGIN = '1999-01-01' +END = '3000-01-01' + + +#mysql_promotion_config = {'user': 'mytga', 'pswd': 'gzVwh4HGR68G', 'host': '10.10.3.5', 'db': 'games_report'} +#redis_company_config = {'host': '10.10.3.10', 'port': 6379, 'db': 2}