Files
bl/modules/blazing/service/talkconfig.go

36 lines
781 B
Go
Raw Normal View History

package service
import (
"blazing/cool"
"blazing/modules/blazing/model"
"context"
"github.com/gogf/gf/v2/os/gcache"
)
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 {
ret, _ := s.Cache.GetOrSetFuncLock(context.Background(), flag, func(context.Context) (interface{}, error) {
var config []model.MineralCollectionConfig
cool.DBM(s.Model).Where("type", flag).Scan(&config)
return config, nil
}, 0)
return ret.Interface().([]model.MineralCollectionConfig)
}