Class: Redis::DistributedStore

Inherits:
Distributed
  • Object
show all
Defined in:
lib/redis/distributed_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(addresses, options = { }) ⇒ DistributedStore

Returns a new instance of DistributedStore.



5
6
7
8
9
10
11
# File 'lib/redis/distributed_store.rb', line 5

def initialize(addresses, options = { })
  nodes = addresses.map do |address|
    ::Redis::Store.new address
  end
  _extend_namespace options
  @ring = Redis::HashRing.new nodes
end

Instance Attribute Details

#ringObject (readonly)

Returns the value of attribute ring.



3
4
5
# File 'lib/redis/distributed_store.rb', line 3

def ring
  @ring
end

Instance Method Details

#get(key, options = nil) ⇒ Object



21
22
23
# File 'lib/redis/distributed_store.rb', line 21

def get(key, options = nil)
  node_for(key).get(key, options)
end

#nodesObject



13
14
15
# File 'lib/redis/distributed_store.rb', line 13

def nodes
  ring.nodes
end

#set(key, value, options = nil) ⇒ Object



17
18
19
# File 'lib/redis/distributed_store.rb', line 17

def set(key, value, options = nil)
  node_for(key).set(key, value, options)
end

#setnx(key, value, options = nil) ⇒ Object



25
26
27
# File 'lib/redis/distributed_store.rb', line 25

def setnx(key, value, options = nil)
  node_for(key).setnx(key, value, options)
end