diff --git a/pool.go b/pool.go index 6fe4538..fed110d 100644 --- a/pool.go +++ b/pool.go @@ -35,6 +35,7 @@ type pool interface { type conn struct { netcn net.Conn rd *bufio.Reader + buf []byte inUse bool usedAt time.Time @@ -53,6 +54,7 @@ func newConnFunc(dial func() (net.Conn, error)) func() (*conn, error) { } cn := &conn{ netcn: netcn, + buf: make([]byte, 0, 64), } cn.rd = bufio.NewReader(cn) return cn, nil diff --git a/redis.go b/redis.go index 1c5f6c3..6c64225 100644 --- a/redis.go +++ b/redis.go @@ -14,7 +14,7 @@ type baseClient struct { } func (c *baseClient) writeCmd(cn *conn, cmds ...Cmder) error { - buf := make([]byte, 0, 64) + buf := cn.buf[:0] for _, cmd := range cmds { buf = appendArgs(buf, cmd.args()) }