go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

SentinelClient has no Masters method

Open heyitsols opened this issue 5 years ago • 3 comments

I get the following when trying to use SentinelClient.Masters()

sentinel.Masters undefined (type *redis.SentinelClient has no field or method Masters)

My code is as follows:

sentinel := redis.NewSentinelClient(&redis.Options{
	Addr:     "redis-ha:26379",
	Password: "",
})
master := sentinel.Masters()

I'm not 100% that this will bring me back the masters, but I can't check that because I get the error above. This is using redis 5.0.6 and golang 1.12

heyitsols avatar Oct 01 '19 20:10 heyitsols

Just for context I’ve moved from a single redis to a sentinel setup, and previous I was using NewClient() but that will attempt to connect to a slave sometimes and fail to write, so I want to connect to the master only when doing writes

heyitsols avatar Oct 01 '19 20:10 heyitsols

with multi sentinels you should use redis.NewFailoverClient then program will connect to master when write

Queetinliu avatar Nov 02 '22 04:11 Queetinliu

This issue is marked stale. It will be closed in 30 days if it is not updated.

github-actions[bot] avatar Feb 27 '24 00:02 github-actions[bot]