✨ feat(cache): 新增 Redis 缓存与 PostgreSQL 后端支持
- 新增 cache.redis 配置(独立 host/port/password/db 字段),启用后正文缓存与音频代理缓存走 Redis,键前缀 fq:cache:/fq:audio:,TTL 自动过期 - 新增 cache.backend: sqlite|postgres 切换,PG 连接用 net/url 构造 DSN,密码特殊字符自动转义;SQLite 顺手启用 WAL 与 busy_timeout - SQL 方言收敛:q() 将 ? 占位符转换为 $n、INSERT OR IGNORE 与查询再插入统一为 ON CONFLICT、LastInsertId 改为 RETURNING id、建表 DDL 双版本分派 - PG 下 VACUUM 走 autovacuum 说明、状态页大小改查 pg_database_size - 修复 PG 下设备保存失败:is_valid 列为 INTEGER,写入点补 boolToInt 转换 - 新增 .env 支持:敏感配置(密码/主机/访问密钥)由环境变量覆盖 config.yaml,.env 进 gitignore,仓库附 .env.example 模板 - 删除死代码 InitDevicePoolTable;新增 rebind_test.go 单测 - 更新 README 与 config.yaml 配置示例,go.mod 新增 go-redis/v9 与 pgx/v5 依赖
This commit is contained in:
1 parent
d710d382ee
commit
cf16c37f32
14 files changed
+671
-210
No files matched your search
@@ -33,6 +33,13 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
defer fqapi.CloseCache() // 程序退出时关闭数据库
|
||||
|
||||
// 初始化 Redis 缓存(可选)
|
||||
if err := fqapi.InitRedis(); err != nil {
|
||||
logger.Error("Redis 初始化失败: " + err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
defer fqapi.CloseRedis()
|
||||
|
||||
// 加载统计数据
|
||||
handlers.LoadStatistics()
|
||||
|
||||
Reference in new issue
Block a user