Class: ActiveSupport::Cache::Bin
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::Bin
- Defined in:
- lib/active_support/cache/bin.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #clear ⇒ Object
- #decrement(key, amount = 1, options = nil) ⇒ Object
- #delete_matched(matcher, options = nil) ⇒ Object
- #expires_in ⇒ Object
- #increment(key, amount = 1, options = nil) ⇒ Object
-
#initialize(collection, options = {}) ⇒ Bin
constructor
A new instance of Bin.
- #stats ⇒ Object
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, ={}) @collection, @options = collection, end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
6 7 8 |
# File 'lib/active_support/cache/bin.rb', line 6 def collection @collection end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/active_support/cache/bin.rb', line 6 def @options end |
Instance Method Details
#clear ⇒ Object
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, =nil) counter_key_upsert(:decrement, key, -amount.abs, ) end |
#delete_matched(matcher, options = nil) ⇒ Object
16 17 18 |
# File 'lib/active_support/cache/bin.rb', line 16 def delete_matched(matcher, =nil) collection.remove(:_id => matcher) end |
#expires_in ⇒ Object
12 13 14 |
# File 'lib/active_support/cache/bin.rb', line 12 def expires_in @expires_in ||= [: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, =nil) counter_key_upsert(:increment, key, amount, ) end |
#stats ⇒ Object
32 33 34 |
# File 'lib/active_support/cache/bin.rb', line 32 def stats collection.stats end |