I use newPool to init redis.Pool
var (
Pool *redis.Pool
)
func newPool(server string) *redis.Pool {
return &redis.Pool{
MaxIdle: 3,
IdleTimeout: 240 * time.Second,
Dial: func() (redis.Conn, error) {
redisPwd, _ := misc.AppConf.Get("redis_pwd") // get password from config
conn, err := redis.Dial("tcp", server, redis.DialPassword(redisPwd))
if err != nil {
return nil, err
}
return conn, nil
},
TestOnBorrow: func(c redis.Conn, t time.Time) error {
_, err := c.Do("PING")
return err
},
}
}
Try to connect redis DB
func TestRedis(t *testing.T) {
InitRedis()
redisConn := Pool.Get()
keys, err := redis.Strings(redisConn.Do("kEYS", "*"))
if err != nil {
t.Fatal(err)
}
fmt.Printf("%v\n", keys)
time.Sleep(time.Hour)
}
While connecting 3.0 version redis DB , it return error : ERR Client sent AUTH, but no password is set
The error message describes the problem. Either skip sending the password or set a password in the server's config.
@garyburd I have the same problem. I've set the requirepass in redis.windows.conf and run redis.exe with that config. When I do the pool connection, it says: Redis set failed: ERR Client sent AUTH, but no password is set
no password is set
Did you set a password in the configuration file and is that configuration file used by the server?
no password is set
Did you set a password in the configuration file?
Sorry, my bad. I mixed up my two Redis servers. Everything works fine now.
Most helpful comment
Did you set a password in the configuration file and is that configuration file used by the server?