Class: ActiveSupport::Cache::MongoidStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::MongoidStore
- Defined in:
- lib/active_support/cache/mongoid_store.rb
Instance Attribute Summary collapse
-
#collection_name ⇒ Object
readonly
Returns the value of attribute collection_name.
Instance Method Summary collapse
- #cleanup(options = nil) ⇒ Object
- #clear(options = nil) ⇒ Object
- #delete_matched(matcher, options = nil) ⇒ Object
-
#initialize(options = {}) ⇒ MongoidStore
constructor
A new instance of MongoidStore.
Constructor Details
#initialize(options = {}) ⇒ MongoidStore
Returns a new instance of MongoidStore.
9 10 11 12 13 |
# File 'lib/active_support/cache/mongoid_store.rb', line 9 def initialize( = {}) @collection_name = [:collection] || :cache [:expires_in] ||= 1.hour super() end |
Instance Attribute Details
#collection_name ⇒ Object (readonly)
Returns the value of attribute collection_name.
7 8 9 |
# File 'lib/active_support/cache/mongoid_store.rb', line 7 def collection_name @collection_name end |
Instance Method Details
#cleanup(options = nil) ⇒ Object
19 20 21 22 |
# File 'lib/active_support/cache/mongoid_store.rb', line 19 def cleanup( = nil) = () collection.find(expires_at: {'$lt' => Time.now.utc.to_i}).remove_all end |
#clear(options = nil) ⇒ Object
15 16 17 |
# File 'lib/active_support/cache/mongoid_store.rb', line 15 def clear( = nil) collection.find.remove_all end |
#delete_matched(matcher, options = nil) ⇒ Object
24 25 26 27 |
# File 'lib/active_support/cache/mongoid_store.rb', line 24 def delete_matched(matcher, = nil) = () collection.find(_id: key_matcher(matcher, )).remove_all end |