|
@@ -217,7 +217,7 @@ func GetInfoTitle(info map[string]interface{}) string {
|
|
}
|
|
}
|
|
|
|
|
|
//加载数据到内存中
|
|
//加载数据到内存中
|
|
-func LoadBidding(mgo *MongodbSim, dbName, coll, incField string, startTime int64, redisCache bool, query map[string]interface{}, fields map[string]interface{}) (*[]map[string]interface{}, int64) {
|
|
|
|
|
|
+func LoadBidding(mgo *MongodbSim, dbName, coll, incField string, startTime, maxSize int64, redisCache bool, query, fields map[string]interface{}) (*[]map[string]interface{}, int64) {
|
|
defer util.Catch()
|
|
defer util.Catch()
|
|
endTime := time.Now().Unix()
|
|
endTime := time.Now().Unix()
|
|
if query == nil || len(query) == 0 {
|
|
if query == nil || len(query) == 0 {
|
|
@@ -277,7 +277,7 @@ func LoadBidding(mgo *MongodbSim, dbName, coll, incField string, startTime int64
|
|
sess := mgo.GetMgoConn()
|
|
sess := mgo.GetMgoConn()
|
|
defer mgo.DestoryMongoConn(sess)
|
|
defer mgo.DestoryMongoConn(sess)
|
|
it := sess.DB(dbName).C(coll).Find(query).Select(queryField).Iter()
|
|
it := sess.DB(dbName).C(coll).Find(query).Select(queryField).Iter()
|
|
- index := 0
|
|
|
|
|
|
+ var index int64
|
|
for temp := make(map[string]interface{}); it.Next(&temp); {
|
|
for temp := make(map[string]interface{}); it.Next(&temp); {
|
|
_id := BsonIdToSId(temp["_id"])
|
|
_id := BsonIdToSId(temp["_id"])
|
|
if publishtime := util.Int64All(temp["publishtime"]); startTime-publishtime > 7*86400 {
|
|
if publishtime := util.Int64All(temp["publishtime"]); startTime-publishtime > 7*86400 {
|
|
@@ -312,6 +312,9 @@ func LoadBidding(mgo *MongodbSim, dbName, coll, incField string, startTime int64
|
|
if index%500 == 0 {
|
|
if index%500 == 0 {
|
|
logger.Info("加载", coll, "数据:", index)
|
|
logger.Info("加载", coll, "数据:", index)
|
|
}
|
|
}
|
|
|
|
+ if maxSize > 0 && index == maxSize {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if util.IntAll(queryField["filetext"]) > 0 {
|
|
if util.IntAll(queryField["filetext"]) > 0 {
|
|
BiddingRepair(res, "filetext")
|
|
BiddingRepair(res, "filetext")
|