Class: RedisMemo::Redis
- Inherits:
-
Redis::Distributed
- Object
- Redis::Distributed
- RedisMemo::Redis
- Defined in:
- lib/redis_memo/redis.rb
Overview
Redis::Distributed does not support reading from multiple read replicas. This class adds this functionality
Defined Under Namespace
Classes: WithReplicas
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Redis
constructor
A new instance of Redis.
Constructor Details
#initialize(options = {}) ⇒ Redis
Returns a new instance of Redis.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/redis_memo/redis.rb', line 10 def initialize(={}) clients = if .is_a?(Array) .map do |option| if option.is_a?(Array) RedisMemo::Redis::WithReplicas.new(option) else option[:logger] ||= RedisMemo::DefaultOptions.logger ::Redis.new(option) end end else [:logger] ||= RedisMemo::DefaultOptions.logger [::Redis.new()] end # Pass in our own hash ring to use the clients with multi-read-replica # support hash_ring = Redis::HashRing.new(clients) super([], ring: hash_ring) end |