1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

multi: Improve API.

This commit is contained in:
Vladimir Mihailenco
2012-08-13 14:45:32 +03:00
parent 59f901d62f
commit 625adac9ab
4 changed files with 161 additions and 147 deletions

View File

@ -40,7 +40,7 @@ func PackReq(args []string) []byte {
type ReadLiner interface {
ReadLine() ([]byte, bool, error)
Peek(n int) ([]byte, error)
Read([]byte) (int, error)
ReadN(n int) ([]byte, error)
}
@ -121,13 +121,14 @@ func ParseReply(rd ReadLiner) (interface{}, error) {
line, err = rd.ReadN(replyLen)
if err == bufio.ErrBufferFull {
buf := make([]byte, replyLen)
r := 0
r := copy(buf, line)
r += copy(buf, line)
for err == bufio.ErrBufferFull {
line, err = rd.ReadN(replyLen - r)
r += copy(buf[r:], line)
for r < replyLen {
n, err := rd.Read(buf[r:])
if err != nil {
return "", err
}
r += n
}
line = buf