优化游戏数据批量持久化性能
- 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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user