瀏覽代碼

fix:缓存清除

Roc 2 年之前
父節點
當前提交
23d134491f
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      controllers/base_from_calculate.go

+ 3 - 1
controllers/base_from_calculate.go

@@ -545,7 +545,6 @@ func (this *CalculateController) Refresh() {
 	br := new(models.BaseResponse).Init()
 	var cacheKey string
 	defer func() {
-		utils.Rc.Delete(cacheKey)
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
@@ -576,6 +575,9 @@ func (this *CalculateController) Refresh() {
 	cacheKey = utils.CACHE_EDB_DATA_REFRESH + strconv.Itoa(edbInfo.Source) + "_" + req.EdbCode
 	if !utils.Rc.IsExist(cacheKey) {
 		utils.Rc.SetNX(cacheKey, 1, 1*time.Minute)
+		defer func() {
+			utils.Rc.Delete(cacheKey)
+		}()
 
 		startDate := req.StartDate
 		var errMsg string