示例#1
0
文件: pool.go 项目: ratanbu/redis
func newConn(netcn net.Conn) *conn {
	cn := &conn{
		Cn: netcn,
	}
	cn.Rd = bufio.NewReaderSize(cn, 1024)
	return cn
}
示例#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"})
}
示例#3
0
文件: req_test.go 项目: jahfer/redis
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)
	}
}
示例#4
0
文件: connpool.go 项目: jahfer/redis
func NewConn(rw net.Conn) *Conn {
	return &Conn{
		RW: rw,
		Rd: bufio.NewReaderSize(rw, 1024),
	}
}