上传客户端redis链接池优化
This commit is contained in:
parent
ba2f8c4ba2
commit
90b70f315f
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/go-redis/redis/v8"
|
"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,
|
codec core.ICodec,
|
||||||
) (sys *Redis, err error) {
|
) (sys *Redis, err error) {
|
||||||
var (
|
var (
|
||||||
@ -18,6 +18,7 @@ func NewSys(RedisUrl []string, RedisPassword string, poolSize int, timeOut time.
|
|||||||
Addrs: RedisUrl,
|
Addrs: RedisUrl,
|
||||||
Password: RedisPassword,
|
Password: RedisPassword,
|
||||||
PoolSize: poolSize,
|
PoolSize: poolSize,
|
||||||
|
MinIdleConns: minConns,
|
||||||
DialTimeout: timeOut,
|
DialTimeout: timeOut,
|
||||||
ReadTimeout: timeOut,
|
ReadTimeout: timeOut,
|
||||||
WriteTimeout: timeOut,
|
WriteTimeout: timeOut,
|
||||||
|
@ -23,6 +23,7 @@ type Options struct {
|
|||||||
Redis_Cluster_Addr []string
|
Redis_Cluster_Addr []string
|
||||||
Redis_Cluster_Password string
|
Redis_Cluster_Password string
|
||||||
PoolSize int
|
PoolSize int
|
||||||
|
MinConns int
|
||||||
TimeOut time.Duration
|
TimeOut time.Duration
|
||||||
Codec core.ICodec
|
Codec core.ICodec
|
||||||
}
|
}
|
||||||
@ -82,7 +83,8 @@ func newOptions(config map[string]interface{}, opts ...Option) Options {
|
|||||||
Redis_Single_DB: 1,
|
Redis_Single_DB: 1,
|
||||||
Redis_Cluster_Addr: []string{"127.0.0.1:6379"},
|
Redis_Cluster_Addr: []string{"127.0.0.1:6379"},
|
||||||
Redis_Cluster_Password: "",
|
Redis_Cluster_Password: "",
|
||||||
PoolSize: 200,
|
PoolSize: 64,
|
||||||
|
MinConns: 32,
|
||||||
TimeOut: time.Second * 3,
|
TimeOut: time.Second * 3,
|
||||||
}
|
}
|
||||||
if config != nil {
|
if config != nil {
|
||||||
@ -101,7 +103,8 @@ func newOptionsByOption(opts ...Option) Options {
|
|||||||
Redis_Single_DB: 1,
|
Redis_Single_DB: 1,
|
||||||
Redis_Cluster_Addr: []string{"127.0.0.1:6379"},
|
Redis_Cluster_Addr: []string{"127.0.0.1:6379"},
|
||||||
Redis_Cluster_Password: "",
|
Redis_Cluster_Password: "",
|
||||||
PoolSize: 200,
|
PoolSize: 64,
|
||||||
|
MinConns: 32,
|
||||||
TimeOut: time.Second * 3,
|
TimeOut: time.Second * 3,
|
||||||
}
|
}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
|
@ -31,6 +31,7 @@ func (this *Redis) init() (err error) {
|
|||||||
this.options.Redis_Single_Password,
|
this.options.Redis_Single_Password,
|
||||||
this.options.Redis_Single_DB,
|
this.options.Redis_Single_DB,
|
||||||
this.options.PoolSize,
|
this.options.PoolSize,
|
||||||
|
this.options.MinConns,
|
||||||
this.options.TimeOut,
|
this.options.TimeOut,
|
||||||
this,
|
this,
|
||||||
)
|
)
|
||||||
@ -39,6 +40,7 @@ func (this *Redis) init() (err error) {
|
|||||||
this.options.Redis_Cluster_Addr,
|
this.options.Redis_Cluster_Addr,
|
||||||
this.options.Redis_Cluster_Password,
|
this.options.Redis_Cluster_Password,
|
||||||
this.options.PoolSize,
|
this.options.PoolSize,
|
||||||
|
this.options.MinConns,
|
||||||
this.options.TimeOut,
|
this.options.TimeOut,
|
||||||
this,
|
this,
|
||||||
)
|
)
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/go-redis/redis/v8"
|
"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,
|
codec core.ICodec,
|
||||||
) (sys *Redis, err error) {
|
) (sys *Redis, err error) {
|
||||||
var (
|
var (
|
||||||
@ -19,6 +19,7 @@ func NewSys(RedisUrl, RedisPassword string, RedisDB int, poolSize int, timeOut t
|
|||||||
Password: RedisPassword,
|
Password: RedisPassword,
|
||||||
DB: RedisDB,
|
DB: RedisDB,
|
||||||
PoolSize: poolSize,
|
PoolSize: poolSize,
|
||||||
|
MinIdleConns: minConns,
|
||||||
DialTimeout: timeOut,
|
DialTimeout: timeOut,
|
||||||
WriteTimeout: timeOut,
|
WriteTimeout: timeOut,
|
||||||
ReadTimeout: timeOut,
|
ReadTimeout: timeOut,
|
||||||
|
Loading…
Reference in New Issue
Block a user