Class: ActiveSupport::Cache::MongoidStore

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @collection_name = options[:collection] || :cache
  options[:expires_in] ||= 1.hour
  super(options)
end

Instance Attribute Details

#collection_nameObject (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(options = nil)
  options = merged_options(options)
  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(options = 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, options = nil)
  options = merged_options(options)
  collection.find(_id: key_matcher(matcher, options)).remove_all
end