Files
bl/modules/blazing/service/talkconfig.go
昔念 56af8951c7 ```
refactor(common): 移除冗余缓存逻辑并统一数据库缓存适配器配置

将项目中多处手动管理的 gcache 缓存替换为数据库内置缓存机制,
提升缓存使用一致性与可维护性。同时,在初始化时增加对数据库
缓存适配器的设置,确保 Redis 模式下缓存生效。

涉及模块:
- common/cool 包下的缓存初始化逻辑调整
- 多个 service 文件中移除 gcache 实例及相关调用
- 使用 gdb.CacheOption 替代原有缓存方法实现数据查询缓存
```
2025-12-15 05:39:11 +08:00

36 lines
664 B
Go

package service
import (
"blazing/cool"
"blazing/modules/blazing/model"
"github.com/gogf/gf/v2/database/gdb"
)
type TalkConfigService struct {
*cool.Service
}
var TalkConfigServiceS = NewTalkConfigService()
func NewTalkConfigService() *TalkConfigService {
return &TalkConfigService{
Service: &cool.Service{Model: model.NewMineralCollectionConfig()},
// Cache: gcache.New()},
}
}
func (s *TalkConfigService) GetCache(flag int) []model.MineralCollectionConfig {
var config []model.MineralCollectionConfig
cool.DBM(s.Model).Where("type", flag).Cache(gdb.CacheOption{
// Duration: time.Hour,
Force: false,
}).Scan(&config)
return config
}