func writeCmd(cn *pool.Conn, cmds ...Cmder) error { cn.Buf = cn.Buf[:0] for _, cmd := range cmds { var err error cn.Buf, err = appendArgs(cn.Buf, cmd.args()) if err != nil { return err } } _, err := cn.Write(cn.Buf) return err }
func parseBytesReply(cn *pool.Conn, line []byte) ([]byte, error) { if isNilReply(line) { return nil, Nil } replyLen, err := strconv.Atoi(bytesToString(line[1:])) if err != nil { return nil, err } b, err := cn.ReadN(replyLen + 2) if err != nil { return nil, err } return b[:replyLen], nil }
func (c *baseClient) initConn(cn *pool.Conn) error { cn.Inited = true if c.opt.Password == "" && c.opt.DB == 0 { return nil } // Temp client for Auth and Select. client := newClient(c.opt, pool.NewSingleConnPool(cn)) if c.opt.Password != "" { if err := client.Auth(c.opt.Password).Err(); err != nil { return err } } if c.opt.DB > 0 { if err := client.Select(c.opt.DB).Err(); err != nil { return err } } return nil }