class ActiveSupport::Cache::MonetaStore
@api public
Public Class Methods
new(options = nil)
click to toggle source
Calls superclass method
# File lib/active_support/cache/moneta_store.rb, line 5 def initialize(options = nil) raise ArgumentError, 'Option :store is required' unless @store = options.delete(:store) @store = ::Moneta.new(@store, :expires => true) if Symbol === @store super(options) extend Strategy::LocalCache end
Public Instance Methods
clear(options = nil)
click to toggle source
# File lib/active_support/cache/moneta_store.rb, line 26 def clear(options = nil) options = merged_options(options) instrument(:clear, nil, nil) do @store.clear(moneta_options(options)) end end
decrement(key, amount = 1, options = nil)
click to toggle source
# File lib/active_support/cache/moneta_store.rb, line 19 def decrement(key, amount = 1, options = nil) options = merged_options(options) instrument(:decrement, key, :amount => amount) do @store.increment(namespaced_key(key, options), -amount, moneta_options(options)) end end
increment(key, amount = 1, options = nil)
click to toggle source
# File lib/active_support/cache/moneta_store.rb, line 12 def increment(key, amount = 1, options = nil) options = merged_options(options) instrument(:increment, key, :amount => amount) do @store.increment(namespaced_key(key, options), amount, moneta_options(options)) end end
Protected Instance Methods
delete_entry(key, options)
click to toggle source
# File lib/active_support/cache/moneta_store.rb, line 45 def delete_entry(key, options) @store.delete(key, moneta_options(options)) true end
read_entry(key, options)
click to toggle source
# File lib/active_support/cache/moneta_store.rb, line 35 def read_entry(key, options) entry = @store.load(key, moneta_options(options)) entry && (ActiveSupport::Cache::Entry === entry ? entry : ActiveSupport::Cache::Entry.new(entry)) end
write_entry(key, entry, options)
click to toggle source
# File lib/active_support/cache/moneta_store.rb, line 40 def write_entry(key, entry, options) @store.store(key, entry, moneta_options(options)) true end
Private Instance Methods
moneta_options(options)
click to toggle source
# File lib/active_support/cache/moneta_store.rb, line 52 def moneta_options(options) options ||= {} options[:expires] = options.delete(:expires_in).to_i if options.include?(:expires_in) options end