优化游戏数据批量持久化性能
- 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:
@@ -75,6 +75,8 @@ type (
|
||||
Cache2Sql(ctx context.Context, add []*entity.GameAct, update []*entity.GameAct)
|
||||
// Cache2AddChan 批量添加数据库
|
||||
Cache2SqlChan(ctx context.Context, addChan chan *entity.GameAct, updateChan chan *entity.GameAct)
|
||||
// SaveV2Batch 批量保存游戏活动数据 (优化版)
|
||||
SaveV2Batch(ctx context.Context, cacheKeys []string) (err error)
|
||||
// 删除缓存key
|
||||
DelCacheKey(ctx context.Context, aid int, uid int64)
|
||||
// 清空GetRedDot缓存
|
||||
|
||||
Reference in New Issue
Block a user