Class: ActiveSupport::Cache::Bin

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, options = {}) ⇒ Bin

Returns a new instance of Bin.



8
9
10
# File 'lib/active_support/cache/bin.rb', line 8

def initialize(collection, options={})
  @collection, @options = collection, options
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



6
7
8
# File 'lib/active_support/cache/bin.rb', line 6

def collection
  @collection
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/active_support/cache/bin.rb', line 6

def options
  @options
end

Instance Method Details

#clearObject



28
29
30
# File 'lib/active_support/cache/bin.rb', line 28

def clear
  collection.remove
end

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



24
25
26
# File 'lib/active_support/cache/bin.rb', line 24

def decrement(key, amount=1, options=nil)
  counter_key_upsert(:decrement, key, -amount.abs, options)
end

#delete_matched(matcher, options = nil) ⇒ Object



16
17
18
# File 'lib/active_support/cache/bin.rb', line 16

def delete_matched(matcher, options=nil)
  collection.remove(:_id => matcher)
end

#expires_inObject



12
13
14
# File 'lib/active_support/cache/bin.rb', line 12

def expires_in
  @expires_in ||= options[:expires_in] || 1.year
end

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



20
21
22
# File 'lib/active_support/cache/bin.rb', line 20

def increment(key, amount=1, options=nil)
  counter_key_upsert(:increment, key, amount, options)
end

#statsObject



32
33
34
# File 'lib/active_support/cache/bin.rb', line 32

def stats
  collection.stats
end