1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-12 14:21:52 +03:00

Use single read and write buffer where possible

This commit is contained in:
Vladimir Mihailenco
2018-08-04 12:19:19 +03:00
parent ad7024da36
commit b576fe91a1
11 changed files with 368 additions and 106 deletions

View File

@ -46,14 +46,15 @@ func firstCmdsErr(cmds []Cmder) error {
}
func writeCmd(cn *pool.Conn, cmds ...Cmder) error {
cn.Wb.Reset()
cn.WB.Reset()
for _, cmd := range cmds {
if err := cn.Wb.Append(cmd.Args()); err != nil {
err := cn.WB.Append(cmd.Args())
if err != nil {
return err
}
}
_, err := cn.Write(cn.Wb.Bytes())
_, err := cn.Write(cn.WB.Flush())
return err
}