from my_config import set_config
from log import Log
from db_helper import RedisHelper

config_, env = set_config()
log_ = Log()


def update_switch():
    """修改召回池分发视频在流量池中存在，该视频是否进行本地分发数-1 开关"""
    key_name = config_.IN_FLOW_POOL_COUNT_SWITCH['key_name']
    value = config_.IN_FLOW_POOL_COUNT_SWITCH['value']
    redis_helper = RedisHelper()
    redis_helper.set_data_to_redis(key_name=key_name, value=value)
    # 移除过期时间，将其转换为永久状态
    redis_helper.persist_key(key_name=key_name)
    log_.info(f"update switch finished, key_name = {key_name}, value = {value}")


if __name__ == '__main__':
    update_switch()
