Skip to content

Commit

Permalink
feat: pool size and max active conns
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jan 17, 2025
1 parent d0ce6ed commit 65643db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/kvtools/valkeyrie v1.0.0
github.com/redis/go-redis/v9 v9.2.1
github.com/redis/go-redis/v9 v9.7.0
github.com/stretchr/testify v1.10.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/kvtools/valkeyrie v1.0.0 h1:LAITop2wPoYCMitR24GZZsW0b57hmI+ePD18VRTtO
github.com/kvtools/valkeyrie v1.0.0/go.mod h1:bDi/OdhJCSbGPMsCgUQl881yuEweKCSItAtTBI+ZjpU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/redis/go-redis/v9 v9.2.1 h1:WlYJg71ODF0dVspZZCpYmoF1+U1Jjk9Rwd7pq6QmlCg=
github.com/redis/go-redis/v9 v9.2.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
16 changes: 11 additions & 5 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ func init() {

// Config the Redis configuration.
type Config struct {
TLS *tls.Config
Username string
Password string
DB int
Sentinel *Sentinel
TLS *tls.Config
Username string
Password string
DB int
Sentinel *Sentinel
PoolSize int
MaxActiveConns int
}

// Sentinel holds the Redis Sentinel configuration.
Expand Down Expand Up @@ -139,6 +141,8 @@ func newClient(endpoints []string, options *Config) (redis.UniversalClient, erro
WriteTimeout: 30 * time.Second,
ContextTimeoutEnabled: true,
TLSConfig: options.TLS,
PoolSize: options.PoolSize,
MaxActiveConns: options.MaxActiveConns,
}

if options.Sentinel.ClusterClient {
Expand All @@ -164,6 +168,8 @@ func newClient(endpoints []string, options *Config) (redis.UniversalClient, erro
opt.Username = options.Username
opt.Password = options.Password
opt.DB = options.DB
opt.PoolSize = options.PoolSize
opt.MaxActiveConns = options.MaxActiveConns
}

// TODO: use *redis.ClusterClient if we support multiple endpoints.
Expand Down

0 comments on commit 65643db

Please sign in to comment.