Exemplo n.º 1
0
func newConn(netcn net.Conn) *conn {
	cn := &conn{
		Cn: netcn,
	}
	cn.Rd = bufio.NewReaderSize(cn, 1024)
	return cn
}
Exemplo n.º 2
0
func (t *ParserTest) TestParseReq(c *C) {
	buf := bytes.NewBufferString("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nhello\r\n")
	rd := bufio.NewReaderSize(buf, 1024)

	args, err := redis.ParseReq(rd)
	c.Check(err, IsNil)
	c.Check(args, DeepEquals, []string{"SET", "key", "hello"})
}
Exemplo n.º 3
0
func (t *RequestTest) benchmarkReq(c *C, reqString string, req redis.Req, checker Checker, expected interface{}) {
	c.StopTimer()

	lineReader := NewLineReader([]byte(reqString))
	rd := bufio.NewReaderSize(lineReader, 1024)

	for i := 0; i < 10; i++ {
		vIface, err := req.ParseReply(rd)
		c.Check(err, IsNil)
		c.Check(vIface, checker, expected)
		req.SetVal(vIface)
	}

	c.StartTimer()

	for i := 0; i < c.N; i++ {
		v, _ := req.ParseReply(rd)
		req.SetVal(v)
	}
}
Exemplo n.º 4
0
func NewConn(rw net.Conn) *Conn {
	return &Conn{
		RW: rw,
		Rd: bufio.NewReaderSize(rw, 1024),
	}
}