diff --git a/clients/redis.go b/clients/redis.go index 7456337d..3dbe3f4d 100644 --- a/clients/redis.go +++ b/clients/redis.go @@ -13,6 +13,7 @@ func NewRedisClient(cfg config.RedisCacheConfig) (redis.UniversalClient, error) Addrs: cfg.Addresses, Username: cfg.Username, Password: cfg.Password, + PoolSize: cfg.PoolSize, MaxRetries: 7, // default value = 3, since MinRetryBackoff = 8 msec & MinRetryBackoff = 512 msec // the redis client will wait up to 1016 msec btw the 7 tries } diff --git a/config/README.md b/config/README.md index d4dbf57c..a1faa238 100644 --- a/config/README.md +++ b/config/README.md @@ -116,6 +116,7 @@ redis: - # example "localhost:6379" username: password: + pool_size: db_index: | default = 0 [optional] # This option is only applicable for non-clustered Redis instance. # Expiration time for cached responses. diff --git a/config/config.go b/config/config.go index dbd0d2af..9a6595fe 100644 --- a/config/config.go +++ b/config/config.go @@ -959,6 +959,7 @@ type RedisCacheConfig struct { Password string `yaml:"password,omitempty"` Addresses []string `yaml:"addresses"` DBIndex int `yaml:"db_index,omitempty"` + PoolSize int `yaml:"pool_size,omitempty"` XXX map[string]interface{} `yaml:",inline"` } diff --git a/config/config_test.go b/config/config_test.go index 72e52b6a..1d07cecc 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -53,6 +53,7 @@ var fullConfig = Config{ Username: "chproxy", Password: "password", Addresses: []string{"127.0.0.1:" + redisPort}, + PoolSize: 10, }, }, }, @@ -913,6 +914,7 @@ caches: password: XXX addresses: - 127.0.0.1:%s + pool_size: 10 max_payload_size: 107374182400 shared_with_all_users: true param_groups: diff --git a/config/testdata/full.yml b/config/testdata/full.yml index 7018fb87..140d6f3c 100644 --- a/config/testdata/full.yml +++ b/config/testdata/full.yml @@ -55,6 +55,7 @@ caches: redis: username: chproxy password: password + pool_size: 10 addresses: - 127.0.0.1:16379 max_payload_size: 107374182400