调整adid_localtionid 为主键
This commit is contained in:
parent
03c9847e8d
commit
efaa1e194a
14
ad_tasks.py
14
ad_tasks.py
@ -47,9 +47,10 @@ def split_ad_info(localtionid, line):
|
|||||||
|
|
||||||
|
|
||||||
def sadd_adkey(key, line, item):
|
def sadd_adkey(key, line, item):
|
||||||
my_redis.sadd(key, line['id'])
|
redis_key = f"{line['id']}_{item}"
|
||||||
|
my_redis.sadd(key, redis_key)
|
||||||
my_redis.expire(key, 60*2)
|
my_redis.expire(key, 60*2)
|
||||||
info_key = f"adinfo::{line['id']}::info"
|
info_key = f"adinfo::{redis_key}::info"
|
||||||
new_line = split_ad_info(item, line)
|
new_line = split_ad_info(item, line)
|
||||||
if new_line:
|
if new_line:
|
||||||
my_redis.hmset(info_key, new_line)
|
my_redis.hmset(info_key, new_line)
|
||||||
@ -128,7 +129,7 @@ def send_cache_data():
|
|||||||
for item in locationid:
|
for item in locationid:
|
||||||
area = get_area_by_locationid(item)
|
area = get_area_by_locationid(item)
|
||||||
for one in area.split(','):
|
for one in area.split(','):
|
||||||
key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{one}::{item}"
|
key = f"ad::{line.get('gameid', 0)}_{item}::{line.get('channelid', 0)}::{one}::{item}"
|
||||||
if int(line['ad_num']) == 0:
|
if int(line['ad_num']) == 0:
|
||||||
sadd_adkey(key, line, item)
|
sadd_adkey(key, line, item)
|
||||||
elif int(line['ad_num']) > 0:
|
elif int(line['ad_num']) > 0:
|
||||||
@ -138,9 +139,10 @@ def send_cache_data():
|
|||||||
if int(line['ad_num']) > int(num):
|
if int(line['ad_num']) > int(num):
|
||||||
sadd_adkey(key, line, item)
|
sadd_adkey(key, line, item)
|
||||||
else:
|
else:
|
||||||
if my_redis.sismember(key, line['id']):
|
redis_key = f"{line['id']}_{item}"
|
||||||
my_redis.srem(key, line['id'])
|
if my_redis.sismember(key, redis_key):
|
||||||
log.info(f"remove {line['id']} from {key}!")
|
my_redis.srem(key, redis_key)
|
||||||
|
log.info(f"remove {redis_key} from {key}!")
|
||||||
else:
|
else:
|
||||||
log.error(f"get ad_num from mysql failed! ad_num={line['ad_num']}")
|
log.error(f"get ad_num from mysql failed! ad_num={line['ad_num']}")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user