maxiaoshan 3 жил өмнө
parent
commit
b2ecce2e68

+ 12 - 10
src/spiderutil/redisclusterutil.go

@@ -23,9 +23,9 @@ func InitRedisCluster(addrs []string) {
 
 //set
 func RedisClusterSet(key string, val interface{}, timeout int) bool {
-	resullt, err := RedisCluster.Set(ctx, key, val, time.Duration(timeout)*time.Second).Result()
-	if err != nil || resullt != "OK" {
-		log.Println("Redis Cluster Set Error:", resullt, err)
+	result, err := RedisCluster.Set(ctx, key, val, time.Duration(timeout)*time.Second).Result()
+	if err != nil || result != "OK" {
+		log.Println("Redis Cluster Set Error:", result, err)
 		return false
 	}
 	return true
@@ -33,16 +33,18 @@ func RedisClusterSet(key string, val interface{}, timeout int) bool {
 
 //get
 func RedisClusterGet(key string) string {
-	resullt, _ := RedisCluster.Get(ctx, key).Result()
-	return resullt
+	result, _ := RedisCluster.Get(ctx, key).Result()
+	return result
 }
 
 //exists
 func RedisClusterExists(key string) bool {
-	resullt, err := RedisCluster.Exists(ctx, key).Result()
-	if err != nil || resullt != 1 {
-		log.Println("Redis Cluster Exists Error:", resullt, err)
-		return false
+	result, err := RedisCluster.Exists(ctx, key).Result()
+	if result == 1 && err == nil {
+		return true
 	}
-	return true
+	if err != nil {
+		log.Println("Redis Cluster Exists Error:", result, err)
+	}
+	return false
 }

+ 7 - 6
src/spiderutil/sysconfig.go

@@ -32,12 +32,13 @@ type config struct {
 	DetailChansize    int                        `json:"detailchansize"` //下载三级页的线程数
 	LogLevel          int                        `json:"logLevel"`       //日志基本1debug 2info 3warn
 	DayNum            int                        `json:"daynum"`
-	Modal             int                        `json:"Modal"`            //1列表页三级页分开采集,0原始采完列表采三级页(7000,7700)
-	IsHistoryEvent    bool                       `json:"ishistoryevent"`   //只有7000为true
-	SiteType          []string                   `json:"sitetype"`         //网站类型
-	SiteColl          string                     `json:"sitecoll"`         //网站表名
-	ThreadBaseNum     int                        `json:"threadbasenum"`    //开启线程的数据基数
-	ThreadUpperLimit  int                        `json:"threadupperlimit"` //总线程上限
+	Modal             int                        `json:"Modal"`             //1列表页三级页分开采集,0原始采完列表采三级页(7000,7700)
+	IsHistoryEvent    bool                       `json:"ishistoryevent"`    //只有7000为true
+	SiteType          []string                   `json:"sitetype"`          //网站类型
+	SiteColl          string                     `json:"sitecoll"`          //网站表名
+	ThreadBaseNum     int                        `json:"threadbasenum"`     //开启线程的数据基数
+	ThreadUpperLimit  int                        `json:"threadupperlimit"`  //总线程上限
+	RedisClusterAddrs []string                   `json:"redisclusteraddrs"` //redis集群地址
 	//补漏
 	Checkmaxpage  map[string]int `json:"checkmaxpage"`
 	CheckHourTime int            `json:"checkhourtime"`

+ 1 - 0
src/spiderutil/upload.go

@@ -82,6 +82,7 @@ func UploadFile(code, fileName, url string, bt []byte) (string, string, string,
 		fileName = name + "." + newFileType
 		if commUsedReg.MatchString(oldFileType) && newFileType != oldFileType {
 			fileName = name + "." + oldFileType
+			newFileType = oldFileType
 			logger.Info("附件类型不同:", newFileType, oldFileType, code, url)
 		}
 	}