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,55 @@
package model
import (
"blazing/cool"
)
// todo 还需要做一个记录任务奖励的表
const TableNameTask = "player_task"
// Task mapped from table <task>
type Task struct {
Base
PlayerID uint64 `gorm:"not null;index:idx_task_by_player_id;comment:'所属玩家ID'" json:"player_id"`
TaskID uint32 `gorm:"not null;comment:'任务ID'" json:"task_id"`
Data string `gorm:"type:jsonb;not null;comment:'全部数据'" json:"data"`
}
// TaskEX 单个任务的详细信息,包含任务步骤状态和整体状态
type TaskEX struct {
Task
Data []uint32 `struc:"[20]byte" orm:"data" json:"data"`
//LastResetTime time.Time `gorm:"not null;comment:'上次重置时间UTC'" json:"last_reset_time"` //这里是每天重置
// Status 任务整体状态0-未接受1-已接受2-已完成未领取3-已完成已领取
// json标签指定JSON字段名与业务状态说明保持一致
//Status byte `json:"status"`
}
// TableName PlayerInfo's table name
func (*Task) TableName() string {
return TableNameTask
}
// GroupName PlayerInfo's table group
func (*Task) GroupName() string {
return "default"
}
func (t *Task) GetData() string {
return t.Data
}
func (t *Task) SetData(t1 string) {
t.Data = t1
}
// NewPlayerInfo create a new PlayerInfo
func NewTask() *Task {
return &Task{
Base: *NewBase(),
}
}
// init 创建表
func init() {
cool.CreateTable(&Task{})
}