上传客户端redis链接池优化

This commit is contained in:
liwei1dao 2023-09-13 17:14:01 +08:00
parent ba2f8c4ba2
commit 90b70f315f
4 changed files with 11 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import (
"github.com/go-redis/redis/v8"
)
func NewSys(RedisUrl []string, RedisPassword string, poolSize int, timeOut time.Duration,
func NewSys(RedisUrl []string, RedisPassword string, poolSize, minConns int, timeOut time.Duration,
codec core.ICodec,
) (sys *Redis, err error) {
var (
@ -18,6 +18,7 @@ func NewSys(RedisUrl []string, RedisPassword string, poolSize int, timeOut time.
Addrs: RedisUrl,
Password: RedisPassword,
PoolSize: poolSize,
MinIdleConns: minConns,
DialTimeout: timeOut,
ReadTimeout: timeOut,
WriteTimeout: timeOut,

View File

@ -23,6 +23,7 @@ type Options struct {
Redis_Cluster_Addr []string
Redis_Cluster_Password string
PoolSize int
MinConns int
TimeOut time.Duration
Codec core.ICodec
}
@ -82,7 +83,8 @@ func newOptions(config map[string]interface{}, opts ...Option) Options {
Redis_Single_DB: 1,
Redis_Cluster_Addr: []string{"127.0.0.1:6379"},
Redis_Cluster_Password: "",
PoolSize: 200,
PoolSize: 64,
MinConns: 32,
TimeOut: time.Second * 3,
}
if config != nil {
@ -101,7 +103,8 @@ func newOptionsByOption(opts ...Option) Options {
Redis_Single_DB: 1,
Redis_Cluster_Addr: []string{"127.0.0.1:6379"},
Redis_Cluster_Password: "",
PoolSize: 200,
PoolSize: 64,
MinConns: 32,
TimeOut: time.Second * 3,
}
for _, o := range opts {

View File

@ -31,6 +31,7 @@ func (this *Redis) init() (err error) {
this.options.Redis_Single_Password,
this.options.Redis_Single_DB,
this.options.PoolSize,
this.options.MinConns,
this.options.TimeOut,
this,
)
@ -39,6 +40,7 @@ func (this *Redis) init() (err error) {
this.options.Redis_Cluster_Addr,
this.options.Redis_Cluster_Password,
this.options.PoolSize,
this.options.MinConns,
this.options.TimeOut,
this,
)

View File

@ -8,7 +8,7 @@ import (
"github.com/go-redis/redis/v8"
)
func NewSys(RedisUrl, RedisPassword string, RedisDB int, poolSize int, timeOut time.Duration,
func NewSys(RedisUrl, RedisPassword string, RedisDB int, poolSize, minConns int, timeOut time.Duration,
codec core.ICodec,
) (sys *Redis, err error) {
var (
@ -19,6 +19,7 @@ func NewSys(RedisUrl, RedisPassword string, RedisDB int, poolSize int, timeOut t
Password: RedisPassword,
DB: RedisDB,
PoolSize: poolSize,
MinIdleConns: minConns,
DialTimeout: timeOut,
WriteTimeout: timeOut,
ReadTimeout: timeOut,