Files
utility_go/service/game_kv.go
ayflying 713a63356e 优化游戏数据批量持久化性能
- gameAct: 新增SaveV2Batch批量处理方法
  - 使用Redis MGET批量获取替代逐个GET
  - 使用WHERE uid IN批量查询替代逐个查询
  - 使用Batch批量插入替代逐条SQL
  - 修复: 只有数据库写入成功后才删除Redis key

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

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

性能提升: 1000条数据从1000次网络请求减少到2-3次
2026-02-26 15:44:14 +08:00

41 lines
1017 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
)
type (
IGameKv interface {
// SavesV1 方法
//
// @Description: 保存用户KV数据列表。
// @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)
}
)
var (
localGameKv IGameKv
)
func GameKv() IGameKv {
if localGameKv == nil {
panic("implement not found for interface IGameKv, forgot register?")
}
return localGameKv
}
func RegisterGameKv(i IGameKv) {
localGameKv = i
}