Class: ActiveSupport::Cache::MonetaStore

Inherits:
Store
  • Object
show all
Defined in:
lib/active_support/cache/moneta_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ MonetaStore

Returns a new instance of MonetaStore

Raises:

  • (ArgumentError)

5
6
7
8
9
10
# 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

Instance Method Details

#clear(options = nil) ⇒ Object


24
25
26
27
28
# File 'lib/active_support/cache/moneta_store.rb', line 24

def clear(options = nil)
  instrument(:clear, nil, nil) do
    @store.clear(moneta_options(options))
  end
end

#decrement(key, amount = 1, options = nil) ⇒ Object


18
19
20
21
22
# File 'lib/active_support/cache/moneta_store.rb', line 18

def decrement(key, amount = 1, options = nil)
  instrument(:decrement, key, :amount => amount) do
    @store.increment(key, -amount, moneta_options(options))
  end
end

#increment(key, amount = 1, options = nil) ⇒ Object


12
13
14
15
16
# File 'lib/active_support/cache/moneta_store.rb', line 12

def increment(key, amount = 1, options = nil)
  instrument(:increment, key, :amount => amount) do
    @store.increment(key, amount, moneta_options(options))
  end
end