promotion/jobs/init_ad.py
2019-07-12 17:34:37 +08:00

47 lines
958 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
from log.mylog import define_logger
import logging
from mysql.mmysql import MysqlBase
from config import mysql_promotion_config
from myredis.myredis import my_redis, expire_time
import datetime
log = logging.getLogger("/data/logs/init_ad_redis.log")
mydb = MysqlBase(**mysql_promotion_config)
class Init_ad_redis():
# 初始化广告信息将广告明细写入缓存Redis
def __init__(self):
pass
def init_redis(self):
now = datetime.datetime.today().strftime("%Y-%m-%d")
ad_list = # get info from redis
data = my_redis.hmget(key)
if not data:
getdata_sql = f"select id,name,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort,gameid,locationid from ad \
where status=2 and ad_num=-1 and begin_time <'{now}' and end_time >'{now}' ;"
data=mydb.query(getdata_sql)
def check_expired(self):
pass
def check_play_num(self):
# not found! get from mysql
# update 2 redis
def post(self):
pass