This commit is contained in:
HuangHai
2026-01-15 07:40:53 +08:00
parent 3e9fc3737e
commit a61e18bf26
6 changed files with 43 additions and 266 deletions

View File

@@ -4,10 +4,26 @@ import uuid
import json
import redis
from Config.Config import (
REDIS_HOST, REDIS_PORT, REDIS_DB, REDIS_PASSWORD,
REDIS_DECODE_RESPONSES, REDIS_MAX_CONNECTIONS
)
try:
from Config.Config import (
REDIS_HOST, REDIS_PORT, REDIS_DB, REDIS_PASSWORD,
REDIS_DECODE_RESPONSES, REDIS_MAX_CONNECTIONS
)
except ModuleNotFoundError:
import importlib.util
import os
_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_config_path = os.path.join(_root_dir, "Config", "Config.py")
_spec = importlib.util.spec_from_file_location("project_config_fallback", _config_path)
_cfg = importlib.util.module_from_spec(_spec)
assert _spec.loader is not None
_spec.loader.exec_module(_cfg)
REDIS_HOST = _cfg.REDIS_HOST
REDIS_PORT = _cfg.REDIS_PORT
REDIS_DB = _cfg.REDIS_DB
REDIS_PASSWORD = getattr(_cfg, "REDIS_PASSWORD", None)
REDIS_DECODE_RESPONSES = _cfg.REDIS_DECODE_RESPONSES
REDIS_MAX_CONNECTIONS = _cfg.REDIS_MAX_CONNECTIONS
# 创建logger实例
logger = logging.getLogger(__name__)