chore: 基线提交(重构前代码快照)
- git 初始化 + .gitignore 补全(根 .env / logs / instance / __pycache__ 等) - 修复 utils/.gitignore 误将整个 utils/ 源码层忽略的问题,补入全部工具源码(含 ip2region.xdb) - 含后端全部代码:application / extensions / utils / config / migrations - 含前端 ui/(后续整体迁走) - 不含根 .env(含密钥,本地保留) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
Redis 缓存配置模块
|
||||
=============================================================
|
||||
|
||||
包含 Redis 连接相关的所有配置项。
|
||||
|
||||
依赖:config/__init__.py 中的 _load_env_file() 已提前加载 .env
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# ============================================================
|
||||
# 缓存配置(Redis)
|
||||
# ============================================================
|
||||
|
||||
# 缓存服务地址
|
||||
REDIS_HOST = os.getenv('REDIS_HOST', '127.0.0.1')
|
||||
|
||||
# 缓存服务端口(Redis默认6379)
|
||||
REDIS_PORT = int(os.getenv('REDIS_PORT', 6379))
|
||||
|
||||
# 缓存服务密码(务必使用强密码)
|
||||
REDIS_PASSWORD = os.getenv('REDIS_PASSWORD', '')
|
||||
|
||||
# 缓存库索引(0-15,不同索引用于不同业务)
|
||||
REDIS_INDEX = int(os.getenv('REDIS_INDEX', 0))
|
||||
|
||||
# 是否需要进行用户认证:True-开启,False-关闭(生产环境必须开启)
|
||||
REDIS_AUTH = os.getenv('REDIS_AUTH', 'True') == 'True'
|
||||
|
||||
# 是否对查询结果进行编码处理:True-自动解码,False-返回字节数据
|
||||
REDIS_DECODE_RESPONSES = os.getenv('REDIS_DECODE_RESPONSES', 'True') == 'True'
|
||||
|
||||
# Redis连接URL(方便直接使用)
|
||||
# 仅在 AUTH 开启且密码非空时才拼入密码,避免密码泄露到日志
|
||||
if REDIS_AUTH and REDIS_PASSWORD:
|
||||
REDIS_URL = f'redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}/{REDIS_INDEX}'
|
||||
else:
|
||||
REDIS_URL = f'redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_INDEX}'
|
||||
Reference in New Issue
Block a user