Closed phuongnd08 closed 4 years ago
I'm working on that right now, I may be able to release something very soon. It won't be a modification on Redic, but a different library that uses Redic.
Awesome. I hope that library you were to mention is Ohm because it's what I'm in need right now :smile:
@soveran I'm working on this: https://github.com/phuongnd08/redic-sentinel Could you give some reviews?
Excellent! I just checked it and I have some questions. You modify the Redic
constant and also Redic::Client
, is that needed to make it work with Ohm?
In general, it is better to use a different constant (for example, RedicSentinel
), and design it so that internally it uses Redic
. The reason for that is because by modifying Redic
itself, you may get conflicts if a library wants to use Redic
in some other way without the sentinel modifications. Ohm allows you to use any client that uses the same API as Redic
, that is, once initialized it should reply to call
, queue
and commit
.
I will review the rest later, but for now we can start thinking about that.
Forgot to mention how to use a different client with Ohm, it goes like this:
Ohm.redis = MyClient.new(...)
As long as the instance of MyClient
responds to call
, queue
and commit
, everything will work.
Cool. I'm just not sure how could commit
be implemented on top of thing like redis-rb
. If we can simplify our project to just redis-rb
rather than redic then I can focus on contribute work to redis-sentinel
rather than fork to the new redic-sentinel
Per your questions, I need to modify the Redic class to be able to pass in sentinels host and port information into Redic.new
. The Redic::Client
listen to change in sentinel to automatically reconnect and also reconnect in case of connection error (old master went off, master became slave)
I fork my work off redis-sentinel
so most of the logic there is just rewritten of redis-sentinel
logics.
How would I setup redic if I want to use multiple redis servers with the possibility of failover (the one that being connected by the client went down)