Question
How to connect to managed Redis database with Golang
I was wondering if anyone has had any experience with using the github.com/go-redis/redis package to connect to a Digital Ocean managed Redis database?
I’ve tried the basic connection from the README file
client := redis.NewClient(&redis.Options{
Addr: "CONNECT_STRING : PORT",
Password: "PASSWORD", // password set
DB: 0, // use default DB
MaxRetries: 3, //added after a google suggestion
})
pong, err = client.Ping().Result()
if err != nil {
fmt.Printf("Cannot Ping: %v\n", err.Error())
} else {
fmt.Printf("Pong: %v\n", pong)
}
But when I come to test the connect, I don’t receive Pong as a reply, I get an error with the message
EOF
And when I come to check the logs in the control panel, I cannot see anything that looks like a connection attempt.
Any help would be greatly appreciated.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×