golang连接redis,遇到报错redis报-ERR max number of clients reached错误。首先是自己的代码里面用到了redis的连接池,
var pool *redis.pool
func main() {
pool = newRedisPool(REDISHOST+":6379", "")
go userLoginLog()
....
}
func userLoginLog() {
for {
redisConn := pool.Get()
defer redisConn.Close()
listLog, err := redis.String(redisConn.Do("LPOP", "list"))
........
}
}
func newRedisPool(server, password string) *redis.Pool {
return &redis.Pool{
MaxIdle: 10,
IdleTimeout: 240 * time.Second,
Dial: func() (redis.Conn, error) {