| 123456789101112131415161718192021222324 |
- package services
- import (
- "app/commons/core/redisclient"
- "app/commons/model/entity"
- "fmt"
- "time"
- )
- // 获取资产配置
- func (s *CommonService) AssetConfigFromCache() (*entity.AssetConfig, error) {
- row := entity.NewAssetConfig()
- cacheKey := fmt.Sprintf("asset:confing")
- cacheTime := time.Second * 30
- err := redisclient.GetJsonDataFromCacheOrDB(cacheKey, cacheTime, &row, func() (interface{}, error) {
- results, err1 := GetLast[entity.AssetConfig](s.DB())
- if err1 != nil {
- return results, fmt.Errorf("AssetConfig get error")
- }
- return results, nil
- })
- return row, err
- }
|