I am using Redigo to connect to redis server through golang.
redisConnection, err = redis.Dial("tcp", "...")
redisConnection.Do(..., ...)
If I restart my server, I am unable to execute any command using the same redisConnection
. Shouldn't it reconnect when I execute Do
again?
No, your assumption is not correct. Using the Dial
function it returns a single connection when the server terminates the connection, the client is not able to reconnect.
You should use redis.Pool
and it should be able to auto-reconnect when you ask for a new connection, the function is: pool.Get()
redisConnection.Err()
returns a non nil value if the connection is not usable. We can Dial
again in that case.