class Redis::DistributedStore
Attributes
ring[R]
Public Class Methods
new(addresses, options = { })
click to toggle source
# File lib/redis/distributed_store.rb, line 8 def initialize(addresses, options = { }) nodes = addresses.map do |address| ::Redis::Store.new _merge_options(address, options) end _extend_namespace options @ring = Redis::HashRing.new nodes end
Public Instance Methods
get(key, options = nil)
click to toggle source
# File lib/redis/distributed_store.rb, line 29 def get(key, options = nil) node_for(key).get(key, options) end
nodes()
click to toggle source
# File lib/redis/distributed_store.rb, line 17 def nodes ring.nodes end
reconnect()
click to toggle source
# File lib/redis/distributed_store.rb, line 21 def reconnect nodes.each {|node| node.reconnect } end
redis_version()
click to toggle source
# File lib/redis/distributed_store.rb, line 37 def redis_version nodes.first.redis_version unless nodes.empty? end
set(key, value, options = nil)
click to toggle source
# File lib/redis/distributed_store.rb, line 25 def set(key, value, options = nil) node_for(key).set(key, value, options) end
setnx(key, value, options = nil)
click to toggle source
# File lib/redis/distributed_store.rb, line 33 def setnx(key, value, options = nil) node_for(key).setnx(key, value, options) end
supports_redis_version?(version)
click to toggle source
# File lib/redis/distributed_store.rb, line 41 def supports_redis_version?(version) if nodes.empty? false else nodes.first.supports_redis_version?(version) end end
Private Instance Methods
_extend_namespace(options)
click to toggle source
# File lib/redis/distributed_store.rb, line 50 def _extend_namespace(options) @namespace = options[:namespace] extend ::Redis::Store::Namespace if @namespace end
_merge_options(address, options)
click to toggle source
# File lib/redis/distributed_store.rb, line 55 def _merge_options(address, options) address.merge({ :timeout => options[:timeout] || @@timeout, :namespace => options[:namespace] }) end