Class: Redis::DistributedStore
- Inherits:
-
Distributed
- Object
- Distributed
- Redis::DistributedStore
- Defined in:
- lib/redis/distributed_store.rb
Instance Attribute Summary collapse
-
#ring ⇒ Object
readonly
Returns the value of attribute ring.
Instance Method Summary collapse
- #get(key, options = nil) ⇒ Object
-
#initialize(addresses, options = { }) ⇒ DistributedStore
constructor
A new instance of DistributedStore.
- #nodes ⇒ Object
- #set(key, value, options = nil) ⇒ Object
- #setnx(key, value, options = nil) ⇒ Object
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, = { }) nodes = addresses.map do |address| ::Redis::Store.new address end _extend_namespace @ring = Redis::HashRing.new nodes end |
Instance Attribute Details
#ring ⇒ Object (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, = nil) node_for(key).get(key, ) end |
#nodes ⇒ Object
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, = nil) node_for(key).set(key, value, ) end |
#setnx(key, value, options = nil) ⇒ Object
25 26 27 |
# File 'lib/redis/distributed_store.rb', line 25 def setnx(key, value, = nil) node_for(key).setnx(key, value, ) end |