|
@@ -511,54 +511,25 @@ func (this *Tags) GetNewBidInfo() (list []map[string]interface{}) {
|
|
|
list = bidInfosByCache(redisKey)
|
|
|
if len(list) == 0 {
|
|
|
list = bidInfosByCache(redisKeySL)
|
|
|
- for {
|
|
|
- if redisLock.TryLock() {
|
|
|
- if len(list) == 0 {
|
|
|
- list = newBidInfos()
|
|
|
- }
|
|
|
- if len(list) > 0 {
|
|
|
- bidInfosToCache(list)
|
|
|
+ if len(list) == 0 {
|
|
|
+ list = newBidInfos()
|
|
|
+ bidInfosToCache(list)
|
|
|
+ } else {
|
|
|
+ go func() {
|
|
|
+ for {
|
|
|
+ if redisLock.TryLock() {
|
|
|
+ bidInfosToCache(newBidInfos())
|
|
|
+ redisLock.Unlock()
|
|
|
+ }
|
|
|
+ ri++
|
|
|
+ if len(list) > 0 || ri >= rn {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(100 * time.Millisecond)
|
|
|
}
|
|
|
- redisLock.Unlock()
|
|
|
- }
|
|
|
- ri++
|
|
|
- if len(list) > 0 || ri >= rn {
|
|
|
- break
|
|
|
- }
|
|
|
- time.Sleep(100 * time.Millisecond)
|
|
|
+ }()
|
|
|
}
|
|
|
}
|
|
|
- //rediskey := fmt.Sprintf("pcindex_newArticle")
|
|
|
- //if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
|
- // list = qu.ObjArrToMapArr(l)
|
|
|
- //} else {
|
|
|
- // // p397 未登录详情页最新招投标信息去掉拟建
|
|
|
- // var (
|
|
|
- // now = time.Now()
|
|
|
- // startTime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix()) //最近7天
|
|
|
- // endTime = fmt.Sprint(now.Unix())
|
|
|
- // publishTime = fmt.Sprintf("%s_%s", startTime, endTime)
|
|
|
- // )
|
|
|
- // _, _, lists := bidsearch.GetPcBidSearchData("", "", "", publishTime, "招标预告,招标公告,招标结果,招标信用信息", "", "", "", "", "", "", "", "", 1, false, nil, bidSearch_field_1, "", false, false, "", 50, "")
|
|
|
- // if lists != nil && len(*lists) > 10 {
|
|
|
- // *lists = (*lists)[0:10]
|
|
|
- // for _, v := range *lists {
|
|
|
- // v["_id"] = encrypt.CommonEncodeArticle("content", v["_id"].(string))
|
|
|
- // delete(v, "toptype")
|
|
|
- // delete(v, "s_subscopeclass")
|
|
|
- // tmpdate := v["publishtime"]
|
|
|
- // v["publishtime"] = qu.Int64All(tmpdate.(float64))
|
|
|
- // v["date"] = time.Unix(qu.Int64All(tmpdate.(float64)), 0).Format(date.Date_Short_Layout)
|
|
|
- // if v["budget"] != nil {
|
|
|
- // v["budget"] = ConversionMoeny(v["budget"])
|
|
|
- // } else if v["bidamount"] != nil {
|
|
|
- // v["budget"] = ConversionMoeny(v["bidamount"])
|
|
|
- // }
|
|
|
- // }
|
|
|
- // list = *lists
|
|
|
- // redis.Put("seoCache", rediskey, list, cacheTime)
|
|
|
- // }
|
|
|
- //}
|
|
|
return list
|
|
|
}
|
|
|
|
|
@@ -822,23 +793,30 @@ func (this *Tags) GetBidding(industry, area, city, stype, keyword string, reques
|
|
|
data, count, b = biddingByCache(rediskey, rediskeyCount)
|
|
|
if data == nil || len(data) == 0 || count == 0 {
|
|
|
data, count, b = biddingByCache(redisKeySL, redisKeyCountSL)
|
|
|
- for {
|
|
|
- if redisLock.TryLock() {
|
|
|
- if data == nil || len(data) == 0 || count == 0 {
|
|
|
- //获取数据库数据
|
|
|
- data, count, b = biddingData()
|
|
|
- }
|
|
|
- //更新缓存
|
|
|
- if data != nil && len(data) > 0 && count > 0 {
|
|
|
- biddingToCache(data, count)
|
|
|
+ if data == nil || len(data) == 0 || count == 0 {
|
|
|
+ data, count, b = biddingData()
|
|
|
+ biddingToCache(data, count)
|
|
|
+ } else {
|
|
|
+ go func() {
|
|
|
+ for {
|
|
|
+ if redisLock.TryLock() {
|
|
|
+ if data == nil || len(data) == 0 || count == 0 {
|
|
|
+ //获取数据库数据
|
|
|
+ data, count, b = biddingData()
|
|
|
+ }
|
|
|
+ //更新缓存
|
|
|
+ if data != nil && len(data) > 0 && count > 0 {
|
|
|
+ biddingToCache(data, count)
|
|
|
+ }
|
|
|
+ redisLock.Unlock()
|
|
|
+ }
|
|
|
+ ri++
|
|
|
+ if (data != nil && len(data) > 0 && count > 0) || ri >= rn {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(100 * time.Millisecond)
|
|
|
}
|
|
|
- redisLock.Unlock()
|
|
|
- }
|
|
|
- ri++
|
|
|
- if (data != nil && len(data) > 0 && count > 0) || ri >= rn {
|
|
|
- break
|
|
|
- }
|
|
|
- time.Sleep(100 * time.Millisecond)
|
|
|
+ }()
|
|
|
}
|
|
|
}
|
|
|
return data, count, b
|