1 回答

TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊
我想用NewClusterClient, 來(lái)回答你的問(wèn)題
我想使用僅連接到集群的一個(gè)端點(diǎn)的客戶(hù)端,并且該端點(diǎn)將確保我獲取或設(shè)置 redis 的密鑰
請(qǐng)確保所有這些參數(shù)都是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 關(guān)注
- 148 瀏覽
添加回答
舉報(bào)