// GetRedisClient returns a redis client that can be used for testing func GetRedisClient() *redis.Client { host := os.Getenv("REDIS_HOST") if host == "" { host = "localhost" } return redis.NewClient(&redis.Options{ Addr: fmt.Sprintf("%s:6379", host), Password: "", // no password set DB: 1, // use default DB }) }
func redisClient() (*redis.Client, error) { redisURL := os.Getenv("REDIS_URL") if redisURL == "" { redisURL = defaultRedisAddr } client := redis.NewClient(&redis.Options{ Addr: redisURL, }) _, err := client.Ping().Result() if err != nil { return nil, err } return client, nil }