Using go-redis with GCP memorystore replicas #2949
Replies: 2 comments
-
hi @davejohnston have you figured out how to use the read replica for reading . in my case , I have a read client and a write client . I am trying to read a key-value using the read client , which errors out. I am able to read/write without any issues using the write client. not sure what the issue is . |
Beta Was this translation helpful? Give feedback.
-
I am not sure how the GCP memorystore is configured, but in Redis, when you have a standalone client you cannot read from the replica, the replica is there to improve availability. As noted by @JavaJourneyer , it will depend on what type of replicas you have configured:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
GCP memory store has a Redis implementation. You can either create a Redis cluster, or you can have a single Redis instance with replicas.
Im able to use the go-redis client to connect to and use the single instance redis, but it doesn't look like there is an option to enable the read only replicas (I do see the ReadOnly option, but the docs/comments suggest it only works for cluster clients)
Has anyone found a way around this, or looked at implementing something that supports it?
Notionally I was thinking we could maintain a map of clients, and keep track of which ones were were only. Ideally a better solution might be something like gorms DBResolver, that picks a primary or replica DB based on the type of command being executed.
Looking at the code that creates the redis client it looks like this
I'm wondering if we could add a field
replicaBaseClients []*baseClient
When were executing the command determine if its readonly or write command?
Beta Was this translation helpful? Give feedback.
All reactions