Combines two stores. One is used as cache, the other as backend adapter.
@example Add `Moneta::Cache` to proxy stack
Moneta.build do use(:Cache) do adapter { adapter :File, :dir => 'data' } cache { adapter :Memory } end end
@api public
@param [Hash] options Options hash @option options [Moneta store] :cache Moneta store used as cache @option options [Moneta store] :adapter Moneta store used as adapter @yieldparam Builder block
# File lib/moneta/cache.rb, line 44 def initialize(options = {}, &block) @cache, @adapter = options[:cache], options[:adapter] DSL.new(self, &block) if block_given? end
(see Proxy#clear)
# File lib/moneta/cache.rb, line 93 def clear(options = {}) @cache.clear(options) @adapter.clear(options) self end
(see Proxy#close)
# File lib/moneta/cache.rb, line 100 def close @cache.close @adapter.close end
(see Proxy#create)
# File lib/moneta/cache.rb, line 77 def create(key, value, options = {}) if @adapter.create(key, value, options) @cache.store(key, value, options) true else false end end
(see Proxy#delete)
# File lib/moneta/cache.rb, line 87 def delete(key, options = {}) @cache.delete(key, options) @adapter.delete(key, options) end
(see Proxy#features)
# File lib/moneta/cache.rb, line 106 def features @features ||= ((@cache.features + [:create, :increment]) & @adapter.features).freeze end
(see Proxy#increment)
# File lib/moneta/cache.rb, line 71 def increment(key, amount = 1, options = {}) @cache.delete(key, options) @adapter.increment(key, amount, options) end
(see Proxy#key?)
# File lib/moneta/cache.rb, line 50 def key?(key, options = {}) @cache.key?(key, options) || @adapter.key?(key, options) end
(see Proxy#load)
# File lib/moneta/cache.rb, line 55 def load(key, options = {}) value = @cache.load(key, options) if value == nil value = @adapter.load(key, options) @cache.store(key, value, options) if value != nil end value end
(see Proxy#store)
# File lib/moneta/cache.rb, line 65 def store(key, value, options = {}) @cache.store(key, value, options) @adapter.store(key, value, options) end
Generated with the Darkfish Rdoc Generator 2.