1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-08 23:42:06 +03:00

feat(proto): add configurable buffer sizes for Redis connections (#3453)

* add configurable buffer sizes for Redis connections

* add MiB to wordlist

* Add description for buffer size parameter
This commit is contained in:
ofekshenawa
2025-08-04 09:16:54 +03:00
committed by GitHub
parent c1f6a04d7c
commit 1eed165f9d
9 changed files with 298 additions and 5 deletions

View File

@@ -12,6 +12,9 @@ import (
"github.com/redis/go-redis/v9/internal/util"
)
// DefaultBufferSize is the default size for read/write buffers (0.5MiB)
const DefaultBufferSize = 512 * 1024
// redis resp protocol data type.
const (
RespStatus = '+' // +<string>\r\n
@@ -58,7 +61,13 @@ type Reader struct {
func NewReader(rd io.Reader) *Reader {
return &Reader{
rd: bufio.NewReader(rd),
rd: bufio.NewReaderSize(rd, DefaultBufferSize),
}
}
func NewReaderSize(rd io.Reader, size int) *Reader {
return &Reader{
rd: bufio.NewReaderSize(rd, size),
}
}