1
0
mirror of https://github.com/redis/go-redis.git synced 2025-10-29 05:29:22 +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

@@ -92,6 +92,20 @@ type ClusterOptions struct {
ConnMaxIdleTime time.Duration
ConnMaxLifetime time.Duration
// ReadBufferSize is the size of the bufio.Reader buffer for each connection.
// Larger buffers can improve performance for commands that return large responses.
// Smaller buffers can improve memory usage for larger pools.
//
// default: 0.5MiB (524288 bytes)
ReadBufferSize int
// WriteBufferSize is the size of the bufio.Writer buffer for each connection.
// Larger buffers can improve performance for large pipelines and commands with many arguments.
// Smaller buffers can improve memory usage for larger pools.
//
// default: 0.5MiB (524288 bytes)
WriteBufferSize int
TLSConfig *tls.Config
// DisableIndentity - Disable set-lib on connect.
@@ -127,6 +141,12 @@ func (opt *ClusterOptions) init() {
if opt.PoolSize == 0 {
opt.PoolSize = 5 * runtime.GOMAXPROCS(0)
}
if opt.ReadBufferSize == 0 {
opt.ReadBufferSize = proto.DefaultBufferSize
}
if opt.WriteBufferSize == 0 {
opt.WriteBufferSize = proto.DefaultBufferSize
}
switch opt.ReadTimeout {
case -1:
@@ -318,6 +338,8 @@ func (opt *ClusterOptions) clientOptions() *Options {
MaxActiveConns: opt.MaxActiveConns,
ConnMaxIdleTime: opt.ConnMaxIdleTime,
ConnMaxLifetime: opt.ConnMaxLifetime,
ReadBufferSize: opt.ReadBufferSize,
WriteBufferSize: opt.WriteBufferSize,
DisableIdentity: opt.DisableIdentity,
DisableIndentity: opt.DisableIdentity,
IdentitySuffix: opt.IdentitySuffix,