|
@@ -275,20 +275,43 @@ func SaveObj(event int, checkAtrr string, data map[string]interface{}, saveredis
|
|
} else {
|
|
} else {
|
|
data["sendflag"] = "true"
|
|
data["sendflag"] = "true"
|
|
}
|
|
}
|
|
- id := MgoS.Save("data_bak", data)
|
|
|
|
- if !flag && id != "" {
|
|
|
|
- href := fmt.Sprint(data["href"])
|
|
|
|
- if len(href) > 5 && saveredis { //有效数据
|
|
|
|
- db := HexToBigIntMod(href) //根据href的哈希值选择Redis的db
|
|
|
|
- //增量
|
|
|
|
|
|
+ href := fmt.Sprint(data["href"])
|
|
|
|
+ if len(href) > 5 && saveredis { //有效数据
|
|
|
|
+ db := HexToBigIntMod(href) //根据href的哈希值选择Redis的db
|
|
|
|
+ //增量
|
|
|
|
+ isExist, _ := util.ExistRedis("title_repeat_judgement", 0, "url_repeat_"+href)
|
|
|
|
+ id := ""
|
|
|
|
+ if !isExist {
|
|
|
|
+ id = mgu.Save("data_bak", "spider", "spider", data)
|
|
|
|
+ } else { //记录重复数据,spider_repeatdata
|
|
|
|
+ mgu.Save("spider_repeatdata", "spider", "spider", data)
|
|
|
|
+ }
|
|
|
|
+ //保存服务未接收成功的数据会存入data_bak中,确保数据不丢失依赖补发程序
|
|
|
|
+ if id != "" {
|
|
util.PutRedis("title_repeat_judgement", 0, "url_repeat_"+href, href, 3600*24*30)
|
|
util.PutRedis("title_repeat_judgement", 0, "url_repeat_"+href, href, 3600*24*30)
|
|
- //全量(判断是否已存在防止覆盖id)
|
|
|
|
- isExist, _ := util.ExistRedis("title_repeat_fulljudgement", db, "url_repeat_"+href)
|
|
|
|
- if !isExist {
|
|
|
|
- util.PutRedis("title_repeat_fulljudgement", db, "url_repeat_"+href, "", -1)
|
|
|
|
|
|
+ if !flag { //保存服务发送成功
|
|
|
|
+ //全量(判断是否已存在防止覆盖id)
|
|
|
|
+ isExist, _ := util.ExistRedis("title_repeat_fulljudgement", db, "url_repeat_"+href)
|
|
|
|
+ if !isExist {
|
|
|
|
+ util.PutRedis("title_repeat_fulljudgement", db, "url_repeat_"+href, "", -1)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // id := MgoS.Save("data_bak", data)
|
|
|
|
+ // if !flag && id != "" {
|
|
|
|
+ // href := fmt.Sprint(data["href"])
|
|
|
|
+ // if len(href) > 5 && saveredis { //有效数据
|
|
|
|
+ // db := HexToBigIntMod(href) //根据href的哈希值选择Redis的db
|
|
|
|
+ // //增量
|
|
|
|
+ // util.PutRedis("title_repeat_judgement", 0, "url_repeat_"+href, href, 3600*24*30)
|
|
|
|
+ // //全量(判断是否已存在防止覆盖id)
|
|
|
|
+ // isExist, _ := util.ExistRedis("title_repeat_fulljudgement", db, "url_repeat_"+href)
|
|
|
|
+ // if !isExist {
|
|
|
|
+ // util.PutRedis("title_repeat_fulljudgement", db, "url_repeat_"+href, "", -1)
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|