Using go-redis with GCP memorystore replicas #2949
Unanswered
davejohnston
asked this question in
Q&A
Replies: 1 comment
-
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.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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