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

@@ -0,0 +1,75 @@
package service
import (
"blazing/cool"
"blazing/modules/player/model"
"github.com/gogf/gf/v2/frame/g"
"github.com/samber/lo"
)
type TitleService struct {
BaseService
}
func (s *TitleService) Get() []uint32 {
m1 := s.TestModel(s.Model)
var talks *model.Title
m1.Scan(&talks)
if talks == nil {
return []uint32{}
}
return talks.AvailableTitle
}
func (s *TitleService) Can(id uint32) bool {
m1 := s.TestModel(s.Model)
var talks *model.Title
m1.Scan(&talks)
if talks == nil {
return false
}
_, ok := lo.Find(talks.AvailableTitle, func(item uint32) bool {
return item == id
})
return ok
}
func (s *TitleService) Give(id uint32) bool {
m1 := s.TestModel(s.Model)
var talks *model.Title
m1.Scan(&talks)
if talks == nil {
m := s.TestModel(s.Model)
data := g.Map{
"player_id": s.userid,
"available_title": []uint32{id},
"is_vip": cool.Config.ServerInfo.IsVip,
}
m.Data(data).Insert()
return true
}
talks.AvailableTitle = append(talks.AvailableTitle, id)
m1.Save()
return true
}
func NewTitleService(id uint32) *TitleService {
return &TitleService{
BaseService: BaseService{userid: id,
Service: &cool.Service{Model: model.NewPlayerTitle()},
},
}
}