Example #1
0
File: yd.go Project: qgweb/new
func main() {
	f, err := os.Open(*fname)
	if err != nil {
		log.Fatalln(err)
	}
	defer f.Close()

	put, err := rediscache.New(rediscache.MemConfig{Host: *put_host, Port: *put_port, Db: *put_db})
	if err != nil {
		log.Fatalln(err)
	}
	defer put.Close()

	dx, err := rediscache.New(rediscache.MemConfig{Host: *dx_host, Port: *dx_port, Db: *dx_db})
	if err != nil {
		log.Fatalln(err)
	}
	defer dx.Close()
	dx.Auth(*dx_auth)
	dx.SelectDb(*dx_db)

	tagAdverts := put.HGetAll(*tagHashKey)
	put.SelectDb(*put_db)

	bi := bufio.NewReader(f)
	for {
		line, err := bi.ReadString('\n')
		if err == io.EOF {
			break
		}
		if err != nil {
			break
		}

		datas := strings.Split(strings.TrimSpace(line), "\t")
		log.Println(len(datas))
		if len(datas) < 3 {
			continue
		}

		ad := datas[0]
		ua := datas[1]
		tags := getTagAdvertHash(datas[2], tagAdverts)
		log.Println(tags)
		put_key := encrypt.DefaultMd5.Encode(ad + "_" + ua)
		log.Println(put_key)
		dx_key := ad + "|" + strings.ToUpper(ua)
		log.Println(dx_key)
		for aid, _ := range tags {
			put.HSet(put_key, "advert:"+aid, aid)
			dx.Set(dx_key, "1")
		}
		put.Expire(put_key, 5400)

	}
	put.Flush()
	put.Flush()
	dx.Flush()
}
Example #2
0
File: fun.go Project: qgweb/new
// 获取redis对象
func GetZJDxRedisObj() (*rediscache.MemCache, error) {
	rurls := strings.Split(GetConfVal("zhejiang::dx_redis_url"), ":")
	conf := rediscache.MemConfig{}
	conf.Host = rurls[0]
	conf.Port = rurls[1]
	return rediscache.New(conf)
}
Example #3
0
File: fun.go Project: qgweb/new
// 获取redis对象
func GetRedisObj() (*rediscache.MemCache, error) {
	rurls := strings.Split(GetConfVal("default::put_redis_url"), ":")
	conf := rediscache.MemConfig{}
	conf.Host = rurls[0]
	conf.Port = rurls[1]
	return rediscache.New(conf)
}
Example #4
0
File: fun.go Project: qgweb/new
// 获取redis对象
func GetPutRedisObj(key string) (conn *rediscache.MemCache, err error) {
	rurls := strings.Split(GetConfVal("default::"+key), ":")
	conf := rediscache.MemConfig{}
	conf.Host = rurls[0]
	conf.Port = rurls[1]
	conf.Db = rurls[2]
	conn, err = rediscache.New(conf)
	conn.SelectDb(conf.Db)
	return
}