1 回答
TA贡献1886条经验 获得超2个赞
我想用NewClusterClient, 来回答你的问题
我想使用仅连接到集群的一个端点的客户端,并且该端点将确保我获取或设置 redis 的密钥
请确保所有这些参数都是false
ReadOnly: false,
RouteRandomly: false,
RouteByLatency: false,
示例代码
import (
goredis "github.com/go-redis/redis/v8"
)
goredis.NewClusterClient(&goredis.ClusterOptions{
Addrs: []string{"cluster-configuration-endpoint:6379"},
Password: "password",
PoolSize: 10,
MinIdleConns: 10,
DialTimeout: 5 * time.Second,
ReadTimeout: 3 * time.Second,
WriteTimeout: 3 * time.Second,
PoolTimeout: 4 * time.Second,
IdleCheckFrequency: 60 * time.Second,
IdleTimeout: 5 * time.Minute,
MaxConnAge: 0 * time.Second,
MaxRetries: 10,
MinRetryBackoff: 8 * time.Millisecond,
MaxRetryBackoff: 512 * time.Millisecond,
TLSConfig: &tls.Config{
InsecureSkipVerify: true,
},
ReadOnly: false,
RouteRandomly: false,
RouteByLatency: false,
})
- 1 回答
- 0 关注
- 117 浏览
添加回答
举报