[英]How to create Redis Transaction in Go using go-redis/redis package?
[英]How to run SENTINEL slaves command using go-redis?
我將Redis客戶端設置如下:
redisClient := redisclient.NewClient(&redisclient.Options{
Addr: <sentinel-pod-IP>:<sentinel-pod-port>,
Password: "",
DB: 0,
})
我通過以下方式運行SENTINEL slaves <master-name>
命令:
import redisclient "github.com/go-redis/redis"
......
cmd := redisclient.NewStringSliceCmd("SENTINEL", "slaves", "master-name")
redisClient.Process(cmd)
slaveInfos, err := cmd.Result()
但是,我在運行redis: can't parse string reply: \\"*40\\"
出錯redis: can't parse string reply: \\"*40\\"
。
SENTINEL get-master-addr-by-name <master-name>
適用於相同的客戶端設置。
我遇到了同樣的問題,並在github上找到了解決方案: https : //github.com/go-redis/redis/issues/788
您需要使用NewSliceCmd
,例如
cmd := redis.NewSliceCmd("sentinel", "slaves", "clusterName-master")
client.Process(cmd)
_, err := cmd.Result()
if err != nil {
fmt.Printf("Unable to issue `sentinel slaves %s-master ` cmd on (%s): %s", clusterName, err.Error())
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.