|
@@ -633,16 +633,16 @@ func (so *SearchOptimize) GetBidSearchQuery() string {
|
|
|
|
|
|
// GetBidSearchListByCache 查询缓存数据
|
|
|
//未登录用户默认搜索和关键词搜索改成500条和免费用户保持一致--需求调整P260来自产品经理杨蘭20220116
|
|
|
-func (so *SearchOptimize) GetBidSearchListByCache() (list []*map[string]interface{}, count int64) {
|
|
|
+func (so *SearchOptimize) GetBidSearchListByCache() (list []*map[string]interface{}, count, total int64) {
|
|
|
//缓存数据 最大量是5000条 100页数据
|
|
|
- l, c := func(so *SearchOptimize) (list []*map[string]interface{}, count int64) {
|
|
|
- //缓存数据: kws.SearchGroup-全部,招标信息,超前信息;kws.PageNum-当前页 免费用户 or 付费用户,BidField:领域化产品
|
|
|
- redisDataKey := fmt.Sprintf(SearchCacheKey, so.SearchGroup, util.If(so.IsPay, "v", "f").(string), util.If(so.BidField != "", so.BidField, "n").(string))
|
|
|
- log.Println("redisDataKey:", redisDataKey)
|
|
|
+ l, c, t := func(so *SearchOptimize) (list []*map[string]interface{}, count, total int64) {
|
|
|
//缓存数据总量 - 当前平台
|
|
|
redisCountKey := fmt.Sprintf(SearchCacheCount, so.SearchGroup, util.If(so.IsPay, "v", "f").(string), util.If(so.BidField != "", so.BidField, "n").(string))
|
|
|
+ total = int64(redis.GetInt(RedisNameNew, redisCountKey))
|
|
|
+ //缓存数据: kws.SearchGroup-全部,招标信息,超前信息;kws.PageNum-当前页 免费用户 or 付费用户,BidField:领域化产品
|
|
|
+ redisDataKey := fmt.Sprintf(SearchCacheKey, so.SearchGroup, util.If(so.IsPay, "v", "f").(string), util.If(so.BidField != "", so.BidField, "n").(string))
|
|
|
+ log.Println("-------redisDataKey:------", redisDataKey)
|
|
|
sCache, err := redis.GetNewBytes(RedisNameNew, redisDataKey)
|
|
|
- count = int64(redis.GetInt(RedisNameNew, redisCountKey))
|
|
|
if err == nil {
|
|
|
if sCache != nil && len(*sCache) > 0 {
|
|
|
err = json.Unmarshal(*sCache, &list)
|
|
@@ -656,13 +656,9 @@ func (so *SearchOptimize) GetBidSearchListByCache() (list []*map[string]interfac
|
|
|
//查询缓存数据 参数初始化
|
|
|
so.DefaultSearchParamsAuto()
|
|
|
//缓存数据
|
|
|
- count, _, list = so.GetBidSearchList(true)
|
|
|
- limitCount := int64(bidsearch.SearchPageSize_PC * util.If(so.IsPay, bidsearch.SearchMaxPageNum_PAYED, bidsearch.SearchMaxPageNum_PC).(int))
|
|
|
- if count > limitCount {
|
|
|
- count = limitCount
|
|
|
- }
|
|
|
+ count, total, list = so.GetBidSearchList(true)
|
|
|
if len(list) > 0 {
|
|
|
- redis.Put(RedisNameNew, redisCountKey, count, 16*60*60)
|
|
|
+ redis.Put(RedisNameNew, redisCountKey, total, 16*60*60)
|
|
|
b, err := json.Marshal(list)
|
|
|
if err == nil {
|
|
|
if err = redis.PutBytes(RedisNameNew, redisDataKey, &b, 16*60*60); err != nil {
|
|
@@ -677,8 +673,9 @@ func (so *SearchOptimize) GetBidSearchListByCache() (list []*map[string]interfac
|
|
|
return
|
|
|
}(so)
|
|
|
if len(l) > 0 {
|
|
|
- list = l[(so.PageNum-1)*so.PageSize : so.PageNum*so.PageSize]
|
|
|
+ total = t
|
|
|
count = c
|
|
|
+ list = l[(so.PageNum-1)*so.PageSize : so.PageNum*so.PageSize]
|
|
|
}
|
|
|
return
|
|
|
}
|