123456789101112131415161718192021222324252627282930313233 |
- package cache
- import (
- "fmt"
- "hongze/hz_crm_api/models/yb"
- "hongze/hz_crm_api/utils"
- "strconv"
- "time"
- )
- func GetYbConfigIntValueByCode(key string) (num int, err error) {
- redisKey := utils.CACHE_ADMIN_YB_CONFIG + key
- max := utils.Rc.Get(redisKey)
- var item *yb.Config
- if max == nil {
- item, err = yb.GetConfigByCode(key)
- if err != nil {
- return
- }
- num, err = strconv.Atoi(item.ConfigValue)
- if err != nil {
- return
- }
- //插入redis
- if !utils.Rc.SetNX(redisKey, num, 2*time.Hour) {
- fmt.Println("setNX Err")
- }
- return
- } else {
- num, err = strconv.Atoi(fmt.Sprintf("%s", max))
- return
- }
- }
|