예제 #1
0
func NewRedisStore(hostPort string, database int) *RedisStore {
	client := redis.NewTCPClient(&redis.Options{
		Addr:     hostPort,
		Password: "", // no password set
		DB:       int64(database),
	})
	return &RedisStore{Client: client}
}
예제 #2
0
func initRedis() {
	redisDB = redis.NewTCPClient(&redis.Options{
		Addr: fmt.Sprintf("%s:%d", "localhost", 6379),
		DB:   int64(1), // use default DB
	})

	fmt.Println(redisDB)
}
예제 #3
0
func (self Connection) Connect() (r *redis.Client, err error) {
	r = redis.NewTCPClient(&redis.Options{
		Addr:     self.Host,
		Password: self.Password,
		DB:       self.Db,
	})

	ping := r.Ping()
	if err = ping.Err(); err != nil {
		return
	}

	return
}