Combines multiple stores. Reads return the result from the first store, writes go to all stores.
@example Add `Moneta::Stack` to proxy stack
Moneta.build do use(:Stack) do add { adapter :Redis } add { adapter :File, :dir => 'data' } add { adapter :File, :dir => 'replicate' } end end
@api public
(see Proxy#clear)
# File lib/moneta/stack.rb, line 86 def clear(options = {}) @stack.each {|s| s.clear(options) } self end
(see Proxy#close)
# File lib/moneta/stack.rb, line 92 def close @stack.each {|s| s.close } nil end
(see Proxy#create)
# File lib/moneta/stack.rb, line 71 def create(key, value, options = {}) last = false @stack.each {|s| last = s.create(key, value, options) } last end
(see Proxy#delete)
# File lib/moneta/stack.rb, line 78 def delete(key, options = {}) @stack.inject(nil) do |value, s| v = s.delete(key, options) value || v end end
(see Proxy#features)
# File lib/moneta/stack.rb, line 98 def features @features ||= begin features = @stack.map(&:features) features.inject(features.first, &:&).freeze end end
(see Proxy#increment)
# File lib/moneta/stack.rb, line 64 def increment(key, amount = 1, options = {}) last = nil @stack.each {|s| last = s.increment(key, amount, options) } last end
(see Proxy#key?)
# File lib/moneta/stack.rb, line 44 def key?(key, options = {}) @stack.any? {|s| s.key?(key, options) } end
(see Proxy#load)
# File lib/moneta/stack.rb, line 49 def load(key, options = {}) @stack.each do |s| value = s.load(key, options) return value if value != nil end nil end
(see Proxy#store)
# File lib/moneta/stack.rb, line 58 def store(key, value, options = {}) @stack.each {|s| s.store(key, value, options) } value end
Generated with the Darkfish Rdoc Generator 2.