mirror of https://github.com/go-redis/redis.git
Add test for reading many keys.
This commit is contained in:
parent
ef0cc25b9b
commit
f14cf3644b
12
parser.go
12
parser.go
|
@ -74,14 +74,14 @@ func readLine(rd reader) ([]byte, error) {
|
|||
}
|
||||
|
||||
func readN(rd reader, n int) ([]byte, error) {
|
||||
buf, err := rd.ReadN(n)
|
||||
b, err := rd.ReadN(n)
|
||||
if err == bufio.ErrBufferFull {
|
||||
newBuf := make([]byte, n)
|
||||
r := copy(newBuf, buf)
|
||||
buf = newBuf
|
||||
newB := make([]byte, n)
|
||||
r := copy(newB, b)
|
||||
b = newB
|
||||
|
||||
for {
|
||||
nn, err := rd.Read(buf[r:])
|
||||
nn, err := rd.Read(b[r:])
|
||||
r += nn
|
||||
if r >= n {
|
||||
// Ignore error if we read enough.
|
||||
|
@ -94,7 +94,7 @@ func readN(rd reader, n int) ([]byte, error) {
|
|||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf, nil
|
||||
return b, nil
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -318,6 +318,15 @@ func (t *RedisTest) TestGetBigVal(c *C) {
|
|||
c.Assert(get.Val(), Equals, val)
|
||||
}
|
||||
|
||||
func (t *RedisTest) TestManyKeys(c *C) {
|
||||
for i := 0; i < 100000; i++ {
|
||||
t.client.Set("keys.key"+strconv.Itoa(i), "hello")
|
||||
}
|
||||
keys := t.client.Keys("keys.*")
|
||||
c.Assert(keys.Err(), IsNil)
|
||||
c.Assert(len(keys.Val()), Equals, 100000)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
func (t *RedisTest) TestConnPoolRemovesBrokenConn(c *C) {
|
||||
|
|
Loading…
Reference in New Issue