Răsfoiți Sursa

Merge branch 'feature/v4.8.40_wky' of qmx/jy into feature/v4.8.40

wangkaiyue 2 ani în urmă
părinte
comite
54e7679e88
1 a modificat fișierele cu 13 adăugiri și 8 ștergeri
  1. 13 8
      src/jfw/front/tags.go

+ 13 - 8
src/jfw/front/tags.go

@@ -24,6 +24,8 @@ import (
 	"app.yhyue.com/moapp/jypkg/public"
 )
 
+const cacheTime = 60 * 60 * 8
+
 // 剑鱼标签页
 type Tags struct {
 	*xweb.Action
@@ -316,7 +318,7 @@ func (this *Tags) GetSEOArea() (provinceArr, cityArr, districtArr []string, name
 		list := public.BaseMysql.SelectBySql(`select name,code,level,pcode from seo_words.seo_area order by code`)
 		//获取组合成必要参数
 		if list != nil && len(*list) > 0 {
-			redis.Put("seoCache", rediskey, *list, -1)
+			redis.Put("seoCache", rediskey, *list, cacheTime)
 			data = *list
 		}
 	}
@@ -413,7 +415,7 @@ func (this *Tags) GetIndustry(industryHref string) interface{} {
 				v: industryMap[v],
 			})
 		}
-		redis.Put("seoCache", rediskey, m, -1)
+		redis.Put("seoCache", rediskey, m, cacheTime)
 		return m
 	}
 	return nil
@@ -452,7 +454,7 @@ func (this *Tags) GetNewBidInfo() (list []map[string]interface{}) {
 				}
 			}
 			list = *lists
-			redis.Put("seoCache", rediskey, list, -1)
+			redis.Put("seoCache", rediskey, list, cacheTime)
 		}
 	}
 	return list
@@ -498,7 +500,7 @@ func (this *Tags) GetStype(href string) (list []map[string]interface{}) {
 			}
 		}
 		list = m
-		redis.Put("seoCache", rediskey, list, -1)
+		redis.Put("seoCache", rediskey, list, cacheTime)
 	}
 	return list
 }
@@ -521,7 +523,7 @@ func (this *Tags) GetConsult() (list []map[string]interface{}) {
 				v["url"] = fmt.Sprintf("/jyblog/%s.html", qu.ObjToString(v["_id"]))
 			}
 			list = *rs
-			redis.Put("seoCache", rediskey, list, -1)
+			redis.Put("seoCache", rediskey, list, cacheTime)
 		}
 	}
 	return list
@@ -575,7 +577,7 @@ func (this *Tags) GetHotLabel(length int64) []map[string]interface{} {
 				})
 			}
 		}
-		redis.Put("seoCache", rediskey, m, -1)
+		redis.Put("seoCache", rediskey, m, cacheTime)
 		return m
 	}
 	return nil
@@ -667,6 +669,9 @@ func (this *Tags) GetBidding(industry, area, city, stype, keyword string, reques
 			currentPage := 5
 			limitcount := qu.IntAllDef(config.Seoconfig["tagsLimitCount"], 50)
 			count := elastic.Count(INDEX, TYPE, query1)
+			if count == 0 {
+				return nil, 0, false
+			}
 			if keyword == "" {
 				r := rand.New(rand.NewSource(time.Now().UnixNano()))
 				startPage = r.Intn(currentPage * limitcount)
@@ -700,8 +705,8 @@ func (this *Tags) GetBidding(industry, area, city, stype, keyword string, reques
 					industry = strings.Split(industry, "_")[0]
 				}
 				public.BidListConvert(industry, datas)
-				redis.Put("seoCache", rediskey, datas, -1)      //生产环境配置4G单独redis,超出4G自动清除
-				redis.Put("seoCache", rediskeyCount, count, -1) //生产环境配置4G单独redis,超出4G自动清除
+				redis.Put("seoCache", rediskey, datas, cacheTime)      //生产环境配置4G单独redis,超出4G自动清除
+				redis.Put("seoCache", rediskeyCount, count, cacheTime) //生产环境配置4G单独redis,超出4G自动清除
 				return *datas, count, false
 			}
 		}