/usr/lib/ruby/vendor_ruby/active_support/cache/moneta_store.rb is in ruby-moneta 0.7.20-2.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | module ActiveSupport
module Cache
# @api public
class MonetaStore < Store
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
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
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
def clear(options = nil)
options = merged_options(options)
instrument(:clear, nil, nil) do
@store.clear(moneta_options(options))
end
end
protected
def read_entry(key, options)
entry = @store.load(key, moneta_options(options))
entry && (ActiveSupport::Cache::Entry === entry ? entry : ActiveSupport::Cache::Entry.new(entry))
end
def write_entry(key, entry, options)
@store.store(key, entry, moneta_options(options))
true
end
def delete_entry(key, options)
@store.delete(key, moneta_options(options))
true
end
private
def moneta_options(options)
options ||= {}
options[:expires] = options.delete(:expires_in).to_i if options.include?(:expires_in)
options
end
end
end
end
|