fix some error
This commit is contained in:
parent
66d1d1bb9a
commit
be0953c837
@ -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)
|
||||
|
@ -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'
|
||||
|
||||
|
11
config_dev.py
Normal file
11
config_dev.py
Normal file
@ -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}
|
Loading…
x
Reference in New Issue
Block a user