feat(cache): 添加复合键缓存操作支持

添加了基于 uint32+string 组合键的缓存操作方法,包括
GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和
ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景

fix(vscode): 添加 cSpell 配置支持 struc 词汇

refactor(session): 移除过时的会话管理方法

移除了基于单一字符串键的会话管理方法,因为已迁移到使用
复合键的缓存操作方式
```
This commit is contained in:
昔念
2026-01-19 18:51:56 +08:00
parent 08ebf849eb
commit 026689f3ed
120 changed files with 1428 additions and 629 deletions

View File

@@ -27,3 +27,12 @@ type ChangePlayerNameOutboundInfo struct {
UserID uint32
Nickname string `struc:"[16]byte"` // 固定长度16字节
}
type ChangeTitleInboundInfo struct {
Head common.TomeeHeader `cmd:"3404" struc:"skip"` //玩家登录
TileID uint32
}
type ChangeTitleOutboundInfo struct {
UserID uint32
TileID uint32
}

View File

@@ -1,12 +1,14 @@
package user
import "blazing/logic/service/common"
import (
"blazing/logic/service/common"
)
//var _ entity.Blazingservice = (*SidInfo)(nil)
type SidInfo struct { //这里直接使用组合来实现将传入的原始头部数据和结构体参数序列化
Head common.TomeeHeader `cmd:"105" struc:"skip"` //玩家登录
Sid []byte `struc:"[20]byte"` // 登录会话ID固定长度16字节
Sid []byte `struc:"[16]byte"` // 登录会话ID固定长度16字节
// ret []byte `struc:"skip"`
}

View File

@@ -2,7 +2,7 @@ package user
import (
"blazing/logic/service/common"
"blazing/modules/blazing/model"
"blazing/modules/player/model"
)
type SimUserInfoInboundInfo struct {

View File

@@ -1,10 +1,11 @@
package user
import (
"blazing/common/data/share"
"blazing/cool"
"blazing/logic/service/common"
"fmt"
"blazing/modules/blazing/model"
"blazing/modules/player/model"
"context"
"encoding/hex"
@@ -23,14 +24,17 @@ func (l *MAIN_LOGIN_IN) CheakSession() bool {
// tt, _ := cool.CacheManager.Keys(context.Background())
//g.Dump(tt)
t1 := hex.EncodeToString(l.Sid)
t, err := share.ShareManager.GetSession(t1)
r, err := cool.CacheManager.Get(context.Background(), fmt.Sprintf("session: %d", l.Head.UserID))
if err != nil {
return false
}
share.ShareManager.DeleteSession(t1)
glog.Debug(context.Background(), "后端获取", t1, t, err)
return t == l.Head.UserID
if r.String() != t1 {
return false
}
cool.CacheManager.Remove(context.Background(), fmt.Sprintf("session: %d", l.Head.UserID))
glog.Debug(context.Background(), "后端获取", t1, err)
return true
}
type LoginMSInfo struct {

31
logic/service/user/cdk.go Normal file
View File

@@ -0,0 +1,31 @@
package user
import "blazing/logic/service/common"
// C2S_GET_GIFT_COMPLETE 礼品兑换完成协议
// 前端到后端
type C2S_GET_GIFT_COMPLETE struct {
Head common.TomeeHeader `cmd:"2801" struc:"skip"`
PassText string `struc:"[16]byte"`
}
// S2C_GET_GIFT_COMPLETE 礼品兑换完成协议
// 后端到前端
type S2C_GET_GIFT_COMPLETE struct {
Flag uint32 `json:"flag"` // 0 代表sdk已被使用 1 表示兑换成功 如果返回0 那么后续数组不需要返回
Tile uint32 `json:"tile"`
GiftListLen uint32 `struc:"sizeof=GiftList"`
GiftList []GiftInfo `json:"giftList"` // 物品id数组
PetGiftLen uint32 `struc:"sizeof=PetGift"`
PetGift []PetGiftInfo `json:"petGiftList"`
}
// GiftInfo 礼品信息
type GiftInfo struct {
GiftID uint32 `json:"giftID"` // 就是物品id
Count uint32 `json:"count"`
}
type PetGiftInfo struct {
PetID uint32 `json:"petID"`
CacthTime uint32 `json:"catchTime"`
}