diff --git a/modules/blazing/service/effect.go b/modules/blazing/service/effect.go index 3f1914aaf..4365b8bbe 100644 --- a/modules/blazing/service/effect.go +++ b/modules/blazing/service/effect.go @@ -13,7 +13,7 @@ type EffectService struct { func (s *EffectService) Args(id uint32) (int, []int) { m := cool.DBM(s.Model).Where("se_idx", id).Cache(gdb.CacheOption{ - // Duration: time.Hour, + //Duration: time.Hour, Force: false, }) diff --git a/modules/dict/service/dict_info.go b/modules/dict/service/dict_info.go index 2c75389a5..aa1216519 100644 --- a/modules/dict/service/dict_info.go +++ b/modules/dict/service/dict_info.go @@ -8,8 +8,8 @@ import ( "blazing/modules/dict/model" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/util/gconv" ) @@ -61,37 +61,37 @@ func (s *DictInfoService) GetData(types string) (data map[uint32]model.DictInfo) dictInfoModel = model.NewDictInfo() dictTypeModel = model.NewDictType() ) - ret, _ := cacheDict.GetOrSetFunc(context.Background(), types, func(context.Context) (interface{}, error) { - // 如果typeData为空, 则返回空 - var ty *model.DictType - mType := cool.DBM(dictTypeModel) - mType.Where("key in (?)", types).Scan(&ty) + // 如果typeData为空, 则返回空 + var ty *model.DictType + mType := cool.DBM(dictTypeModel) + mType.Where("key in (?)", types).Cache(gdb.CacheOption{ + // Duration: time.Hour, - // 如果typeData为空, 则返回空 - if ty == nil { - return []model.DictInfo{}, nil - } - m := cool.DBM(dictInfoModel) - var ress []model.DictInfo - m.Where("typeId", ty.ID).Scan(&ress) - fusions := utils.ToMap(ress, func(t model.DictInfo) uint32 { + Force: false, + }).Scan(&ty) - return gconv.Uint32(t.Value) //物品id转id - }) - return fusions, nil - }, 0) + // 如果typeData为空, 则返回空 + if ty == nil { + return nil + } + m := cool.DBM(dictInfoModel) + var ress []model.DictInfo + m.Where("typeId", ty.ID).Cache(gdb.CacheOption{ + // Duration: time.Hour, - return ret.Interface().(map[uint32]model.DictInfo) + Force: false, + }).Scan(&ress) + fusions := utils.ToMap(ress, func(t model.DictInfo) uint32 { + + return gconv.Uint32(t.Value) //物品id转id + }) + return fusions } -var ( - cacheDict = gcache.New() -) - // ModifyAfter 修改后 func (s *DictInfoService) ModifyAfter(ctx context.Context, method string, param map[string]interface{}) (err error) { - cacheDict.Clear(context.Background()) + if method == "Delete" { // 删除后,同时删除子节点 ids, ok := param["ids"]