47 lines
958 B
Python
47 lines
958 B
Python
# -*- 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
|