Class: ActiveSupport::Cache::MongoDbStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::MongoDbStore
- Defined in:
- lib/active_support/cache/mongo_db_store.rb
Instance Attribute Summary collapse
-
#collection_name ⇒ Object
readonly
Returns the value of attribute collection_name.
Instance Method Summary collapse
- #cleanup(_) ⇒ Object
- #clear ⇒ Object
- #delete_entry(key, _) ⇒ Object
- #delete_matched(matcher, options = nil) ⇒ Object
-
#initialize(options = {}) ⇒ MongoDbStore
constructor
A new instance of MongoDbStore.
Constructor Details
#initialize(options = {}) ⇒ MongoDbStore
Returns a new instance of MongoDbStore.
13 14 15 16 17 |
# File 'lib/active_support/cache/mongo_db_store.rb', line 13 def initialize(={}) @collection_name = [:collection] || :rails_cache [:expires_in] ||= 1.day super() end |
Instance Attribute Details
#collection_name ⇒ Object (readonly)
Returns the value of attribute collection_name.
11 12 13 |
# File 'lib/active_support/cache/mongo_db_store.rb', line 11 def collection_name @collection_name end |
Instance Method Details
#cleanup(_) ⇒ Object
23 24 25 |
# File 'lib/active_support/cache/mongo_db_store.rb', line 23 def cleanup(_) collection.find(expires_at: {'$lt' => Time.now.utc.to_i}).delete_many end |
#clear ⇒ Object
19 20 21 |
# File 'lib/active_support/cache/mongo_db_store.rb', line 19 def clear collection.find.delete_many end |
#delete_entry(key, _) ⇒ Object
34 35 36 |
# File 'lib/active_support/cache/mongo_db_store.rb', line 34 def delete_entry(key, _) collection.find(_id: key).delete_one end |
#delete_matched(matcher, options = nil) ⇒ Object
29 30 31 32 |
# File 'lib/active_support/cache/mongo_db_store.rb', line 29 def delete_matched(matcher, =nil) = () collection.find(_id: key_matcher(matcher, )).delete_many end |