|
@@ -10,6 +10,7 @@ import (
|
|
|
"log"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
+ "sync"
|
|
|
"time"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
@@ -596,21 +597,36 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
|
|
|
}
|
|
|
m[v.InfoId] = true
|
|
|
ids = append(ids, v.InfoId)
|
|
|
+
|
|
|
}
|
|
|
infos := map[string]map[string]interface{}{}
|
|
|
//redis
|
|
|
+ pool := make(chan bool, 3)
|
|
|
+ wait := &sync.WaitGroup{}
|
|
|
+ lock := &sync.Mutex{}
|
|
|
es_ids := []string{}
|
|
|
- for _, v := range ids {
|
|
|
- //剑鱼程序未找到赋值 位置;猜测在推送程序中
|
|
|
- info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
|
|
|
- if info_i != nil {
|
|
|
- info_m, _ := info_i.(map[string]interface{})
|
|
|
- info_m["_id"] = v
|
|
|
- infos[v] = info_m
|
|
|
- } else {
|
|
|
- es_ids = append(es_ids, v)
|
|
|
- }
|
|
|
+ for _, vv := range ids {
|
|
|
+ pool <- true
|
|
|
+ wait.Add(1)
|
|
|
+ go func(v string) {
|
|
|
+ defer func() {
|
|
|
+ <-pool
|
|
|
+ wait.Done()
|
|
|
+ }()
|
|
|
+ //剑鱼程序未找到赋值 位置;猜测在推送程序中
|
|
|
+ info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
|
|
|
+ lock.Lock()
|
|
|
+ defer lock.Unlock()
|
|
|
+ if info_i != nil {
|
|
|
+ info_m, _ := info_i.(map[string]interface{})
|
|
|
+ info_m["_id"] = v
|
|
|
+ infos[v] = info_m
|
|
|
+ } else {
|
|
|
+ es_ids = append(es_ids, v)
|
|
|
+ }
|
|
|
+ }(vv)
|
|
|
}
|
|
|
+ wait.Wait()
|
|
|
//elasticsearch
|
|
|
if len(es_ids) > 0 {
|
|
|
list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
|