Skip to content

Commit 7c4c82c

Browse files
authored
feat: add pool config for redis (#409)
* feat: add pool config for redis Signed-off-by: rfyiamcool <[email protected]> * feat: add pool config for redis Signed-off-by: rfyiamcool <[email protected]> --------- Signed-off-by: rfyiamcool <[email protected]>
1 parent b4ef8e0 commit 7c4c82c

File tree

5 files changed

+6
-0
lines changed

5 files changed

+6
-0
lines changed

clients/redis.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func NewRedisClient(cfg config.RedisCacheConfig) (redis.UniversalClient, error)
1313
Addrs: cfg.Addresses,
1414
Username: cfg.Username,
1515
Password: cfg.Password,
16+
PoolSize: cfg.PoolSize,
1617
MaxRetries: 7, // default value = 3, since MinRetryBackoff = 8 msec & MinRetryBackoff = 512 msec
1718
// the redis client will wait up to 1016 msec btw the 7 tries
1819
}

config/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ redis:
116116
- <string> # example "localhost:6379"
117117
username: <string>
118118
password: <string>
119+
pool_size: <int>
119120
db_index: <int> | default = 0 [optional] # This option is only applicable for non-clustered Redis instance.
120121

121122
# Expiration time for cached responses.

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ type RedisCacheConfig struct {
959959
Password string `yaml:"password,omitempty"`
960960
Addresses []string `yaml:"addresses"`
961961
DBIndex int `yaml:"db_index,omitempty"`
962+
PoolSize int `yaml:"pool_size,omitempty"`
962963
XXX map[string]interface{} `yaml:",inline"`
963964
}
964965

config/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ var fullConfig = Config{
5353
Username: "chproxy",
5454
Password: "password",
5555
Addresses: []string{"127.0.0.1:" + redisPort},
56+
PoolSize: 10,
5657
},
5758
},
5859
},
@@ -913,6 +914,7 @@ caches:
913914
password: XXX
914915
addresses:
915916
- 127.0.0.1:%s
917+
pool_size: 10
916918
max_payload_size: 107374182400
917919
shared_with_all_users: true
918920
param_groups:

config/testdata/full.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ caches:
5555
redis:
5656
username: chproxy
5757
password: password
58+
pool_size: 10
5859
addresses:
5960
- 127.0.0.1:16379
6061
max_payload_size: 107374182400

0 commit comments

Comments
 (0)