Class: ActiveSupport::Cache::MongoidStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::MongoidStore
- Defined in:
- lib/active_support/cache/mongoid-store.rb,
lib/active_support/cache/mongoid_store.rb
Defined Under Namespace
Classes: Entry
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_entry(key, 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.
11 12 13 14 15 |
# File 'lib/active_support/cache/mongoid-store.rb', line 11 def initialize( = {}) @collection_name = [:collection] || :rails_cache [:expires_in] ||= 1.hour super() end |
Instance Attribute Details
#collection_name ⇒ Object (readonly)
Returns the value of attribute collection_name.
9 10 11 |
# File 'lib/active_support/cache/mongoid-store.rb', line 9 def collection_name @collection_name end |
Instance Method Details
#cleanup(options = nil) ⇒ Object
21 22 23 24 |
# File 'lib/active_support/cache/mongoid-store.rb', line 21 def cleanup( = nil) = () collection.find(expires_at: {'$lt' => Time.now.utc.to_i}).remove_all end |
#clear(options = nil) ⇒ Object
17 18 19 |
# File 'lib/active_support/cache/mongoid-store.rb', line 17 def clear( = nil) collection.find.remove_all end |
#delete_entry(key, options = nil) ⇒ Object
31 32 33 |
# File 'lib/active_support/cache/mongoid-store.rb', line 31 def delete_entry(key, = nil) collection.find(_id: key).remove end |
#delete_matched(matcher, options = nil) ⇒ Object
26 27 28 29 |
# File 'lib/active_support/cache/mongoid-store.rb', line 26 def delete_matched(matcher, = nil) = () collection.find(_id: key_matcher(matcher, )).remove_all end |