```
feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
This commit is contained in:
@@ -23,26 +23,13 @@ func NewTaskService() *TaskService {
|
||||
},
|
||||
}
|
||||
}
|
||||
func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
|
||||
func (s *TaskService) Get(id, os int) *model.TaskConfig {
|
||||
var item []model.TaskConfig
|
||||
dbm(s.Model).Where("task_id", id).Scan(&item)
|
||||
var res *model.TaskConfig
|
||||
if len(item) == 1 { //只有一个直接默认
|
||||
if item[0].OutState == os {
|
||||
res = &item[0]
|
||||
}
|
||||
if item[0].OutState < 10 {
|
||||
res = &item[0]
|
||||
}
|
||||
|
||||
}
|
||||
if len(item) > 1 { //
|
||||
|
||||
for _, v := range item {
|
||||
if v.OutState == os {
|
||||
res = &item[os]
|
||||
return res
|
||||
}
|
||||
for _, v := range item {
|
||||
if v.OutState == os {
|
||||
res = &v
|
||||
|
||||
}
|
||||
|
||||
@@ -53,13 +40,20 @@ func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
|
||||
}
|
||||
func (s *TaskService) GetDaily() []model.TaskConfig {
|
||||
var item []model.TaskConfig
|
||||
cool.DBM(s.Model).Where("task_type", 1).
|
||||
Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&item)
|
||||
dbm(s.Model).Where("task_type", 1).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
}
|
||||
func (s *TaskService) IsAcceptable(taskid uint32) bool {
|
||||
|
||||
con, _ := cool.DBM(s.Model).Where("is_acceptable", 1).Where("task_id", taskid).
|
||||
Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Count()
|
||||
|
||||
return con > 0
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user