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 28
def get(key, options = nil)
  node_for(key).get(key, options)
end
nodes() click to toggle source
# File lib/redis/distributed_store.rb, line 16
def nodes
  ring.nodes
end
reconnect() click to toggle source
# File lib/redis/distributed_store.rb, line 20
def reconnect
  nodes.each {|node| node.reconnect }
end
set(key, value, options = nil) click to toggle source
# File lib/redis/distributed_store.rb, line 24
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 32
def setnx(key, value, options = nil)
  node_for(key).setnx(key, value, options)
end

Private Instance Methods

_extend_namespace(options) click to toggle source
# File lib/redis/distributed_store.rb, line 37
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 42
def _merge_options(address, options)
  address.merge(:timeout => options[:timeout] || @@timeout)
end