Bladeren bron

feat:标讯缓存时间调整

fuwencai 2 jaren geleden
bovenliggende
commit
bf529e2908
1 gewijzigde bestanden met toevoegingen van 9 en 2 verwijderingen
  1. 9 2
      src/jfw/modules/app/src/app/jyutil/tags.go

+ 9 - 2
src/jfw/modules/app/src/app/jyutil/tags.go

@@ -468,7 +468,14 @@ func (b *BiddingInfo) GetBiddingInfo(types, name string, currentLocation []*SeoI
 			}
 		} else {
 			if len(currentLocation) > 0 {
+				redisCacheTime := qu.IntAll(config.Seoconfig["biddingCacheTime"])
+				start := time.Now()
+				if b.Keys != "" { // 标的物 一天更新一次
+					redisCacheTime = qu.IntAll(config.Seoconfig["cacheTime"])
+				}
 				count, data := elastic.GetWithCount("bidding", "bidding", "", b.GetSearchSql())
+				fmt.Println("GetWithCount", time.Since(start))
+				fmt.Println(" b.GetSearchSql()", b.GetSearchSql())
 				if count > 0 && data != nil {
 					if b.Total > int(count) {
 						b.Total = int(count)
@@ -496,7 +503,7 @@ func (b *BiddingInfo) GetBiddingInfo(types, name string, currentLocation []*SeoI
 						if len(bir) == 1 {
 							b, err := json.Marshal(bir)
 							if err == nil && len(b) > 0 {
-								if err = redis.PutBytes("seoCache", fmt.Sprintf(biddingListKey, types, name, i+1), &b, qu.IntAll(config.Seoconfig["cacheTime"])+RandNum.Intn(randCount)); err != nil {
+								if err = redis.PutBytes("seoCache", fmt.Sprintf(biddingListKey, types, name, i+1), &b, redisCacheTime+RandNum.Intn(randCount)); err != nil {
 									log.Println(err)
 								}
 							}
@@ -504,7 +511,7 @@ func (b *BiddingInfo) GetBiddingInfo(types, name string, currentLocation []*SeoI
 					}
 					countByte, err := json.Marshal(b.Total)
 					if err == nil && len(countByte) > 0 {
-						if err = redis.PutBytes("seoCache", fmt.Sprintf(biddingListTotalKey, types, name), &countByte, qu.IntAll(config.Seoconfig["cacheTime"])+RandNum.Intn(randCount)); err != nil {
+						if err = redis.PutBytes("seoCache", fmt.Sprintf(biddingListTotalKey, types, name), &countByte, redisCacheTime+RandNum.Intn(randCount)); err != nil {
 							log.Println("存缓存失败:", fmt.Sprintf(biddingListTotalKey, types, name), b.Total)
 						}
 					}