Skip to content

Commit

Permalink
feat: add pool config for redis (#409)
Browse files Browse the repository at this point in the history
* feat: add pool config for redis

Signed-off-by: rfyiamcool <rfyiamcool@163.com>

* feat: add pool config for redis

Signed-off-by: rfyiamcool <rfyiamcool@163.com>

---------

Signed-off-by: rfyiamcool <rfyiamcool@163.com>
  • Loading branch information
rfyiamcool authored Mar 18, 2024
1 parent b4ef8e0 commit 7c4c82c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions clients/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ redis:
- <string> # example "localhost:6379"
username: <string>
password: <string>
pool_size: <int>
db_index: <int> | default = 0 [optional] # This option is only applicable for non-clustered Redis instance.

# Expiration time for cached responses.
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
2 changes: 2 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var fullConfig = Config{
Username: "chproxy",
Password: "password",
Addresses: []string{"127.0.0.1:" + redisPort},
PoolSize: 10,
},
},
},
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions config/testdata/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ caches:
redis:
username: chproxy
password: password
pool_size: 10
addresses:
- 127.0.0.1:16379
max_payload_size: 107374182400
Expand Down

0 comments on commit 7c4c82c

Please sign in to comment.