Class: Herdis::Client::ReDistributed
- Inherits:
-
Redis::Distributed
- Object
- Redis::Distributed
- Herdis::Client::ReDistributed
- Defined in:
- lib/herdis/client.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #add_node(url) ⇒ Object
-
#initialize(urls, options = {}) ⇒ ReDistributed
constructor
A new instance of ReDistributed.
- #node_for(key) ⇒ Object
Constructor Details
#initialize(urls, options = {}) ⇒ ReDistributed
Returns a new instance of ReDistributed.
24 25 26 27 28 29 |
# File 'lib/herdis/client.rb', line 24 def initialize(urls, = {}) @tag = .delete(:tag) || /^\{(.+?)\}/ @default_options = @nodes = urls.map { |url| Redis.connect(.merge(:url => url)) } @subscribed_node = nil end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
22 23 24 |
# File 'lib/herdis/client.rb', line 22 def nodes @nodes end |
Instance Method Details
#add_node(url) ⇒ Object
35 36 37 |
# File 'lib/herdis/client.rb', line 35 def add_node(url) raise "You can't add nodes to #{self}!" end |
#node_for(key) ⇒ Object
31 32 33 |
# File 'lib/herdis/client.rb', line 31 def node_for(key) @nodes[Digest::SHA1.hexdigest(key_tag(key.to_s) || key.to_s).to_i(16) % @nodes.size] end |