Roc 2 years ago
parent
commit
3d1e76eece
1 changed files with 6 additions and 2 deletions
  1. 6 2
      controllers/base_from_wind.go

+ 6 - 2
controllers/base_from_wind.go

@@ -50,7 +50,7 @@ func (this *WindController) Add() {
 			endDate = time.Now().Format(utils.FormatDate)
 		}
 
-		windUrl, err := GetServerUrl()
+		windUrl, err := GetServerUrl(req.EdbCode)
 		if err != nil {
 			br.Msg = "获取使用的wind地址失败!"
 			br.ErrMsg = "获取使用的wind地址失败,err:" + err.Error()
@@ -157,7 +157,7 @@ func (this *WindController) Refresh() {
 }
 
 // GetServerUrl 获取服务器地址
-func GetServerUrl() (windUrl string, err error) {
+func GetServerUrl(edbCode string) (windUrl string, err error) {
 	list, err := models.GetServerUrlCountGroupByServerUrl()
 	if err != nil {
 		return
@@ -178,5 +178,9 @@ func GetServerUrl() (windUrl string, err error) {
 			windUrlNum = tmpNum
 		}
 	}
+
+	// 设置缓存
+	cacheKey := utils.CACHE_WIND_URL + ":" + edbCode
+	_ = utils.Rc.SetNX(cacheKey, windUrl, utils.GetTodayLastSecond())
 	return
 }