优化游戏数据批量持久化性能

- gameAct: 新增SaveV2Batch批量处理方法
  - 使用Redis MGET批量获取替代逐个GET
  - 使用WHERE uid IN批量查询替代逐个查询
  - 使用Batch批量插入替代逐条SQL
  - 修复: 只有数据库写入成功后才删除Redis key

- gameKv: 新增SavesV2Batch批量处理方法
  - 同样的批量优化策略
  - 修复: 只有数据库写入成功后才删除Redis key

- service: 更新接口定义添加新方法

性能提升: 1000条数据从1000次网络请求减少到2-3次
This commit is contained in:
ayflying
2026-02-26 15:44:14 +08:00
parent 8ed8152f79
commit 713a63356e
5 changed files with 397 additions and 80 deletions

View File

@@ -17,6 +17,8 @@ type (
// @receiver s: sGameKv的实例。
// @return err: 错误信息如果操作成功则为nil。
SavesV1() (err error)
// SavesV2Batch 批量保存游戏KV数据 (优化版)
SavesV2Batch(ctx context.Context, cacheKeys []string) (err error)
// 删除缓存key
DelCacheKey(ctx context.Context, uid int64)
}