Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ type Config struct {
//
// NOTE: It's recommended to set short dial/read/write timeouts and disable
// retries on the client, so the local in-memory fallback can activate quickly.
Client redis.UniversalClient `toml:"-"`
Host string `toml:"host"`
Port uint16 `toml:"port"`
Password string `toml:"password"` // optional
DBIndex int `toml:"db_index"` // default: 0
MaxIdle int `toml:"max_idle"` // default: 5
MaxActive int `toml:"max_active"` // default: 10
Client redis.UniversalClient `toml:"-"`
Host string `toml:"host"`
Port uint16 `toml:"port"`
Password string `toml:"password"` // optional
// IsClusterMode is an optional setting that can be used when only one host is provided
// (e.g. Elasticache supports setting up cluster mode with configuration endpoint).
IsClusterMode bool `toml:"is_cluster_mode"` // default: false
DBIndex int `toml:"db_index"` // default: 0
MaxIdle int `toml:"max_idle"` // default: 5
MaxActive int `toml:"max_active"` // default: 10
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.24.1
require (
github.com/alicebob/miniredis/v2 v2.34.0
github.com/go-chi/httprate v0.15.0
github.com/redis/go-redis/v9 v9.7.3
github.com/redis/go-redis/v9 v9.8.0
golang.org/x/sync v0.12.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/go-chi/httprate v0.15.0 h1:j54xcWV9KGmPf/X4H32/aTH+wBlrvxL7P+SdnRqxh5
github.com/go-chi/httprate v0.15.0/go.mod h1:rzGHhVrsBn3IMLYDOZQsSU4fJNWcjui4fWKJcCId1R4=
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI=
github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
Expand Down
9 changes: 5 additions & 4 deletions httprateredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ func NewCounter(cfg *Config) *redisCounter {
}

rc.client = redis.NewUniversalClient(&redis.UniversalOptions{
Addrs: []string{fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)},
Password: cfg.Password,
DB: cfg.DBIndex,
ClientName: cfg.ClientName,
Addrs: []string{fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)},
Password: cfg.Password,
DB: cfg.DBIndex,
ClientName: cfg.ClientName,
IsClusterMode: cfg.IsClusterMode,

DialTimeout: 2 * cfg.FallbackTimeout,
ReadTimeout: cfg.FallbackTimeout,
Expand Down