Class: ActiveSupport::Cache::DbStore

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DbStore

Returns a new instance of DbStore.



9
10
11
12
# File 'lib/active_support/cache/db_store.rb', line 9

def initialize(options = {})
  super(options)
  @repository = options.fetch(:repository, DbItem)
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



7
8
9
# File 'lib/active_support/cache/db_store.rb', line 7

def repository
  @repository
end

Instance Method Details

#cleanup(options = {}) ⇒ Object



18
19
20
# File 'lib/active_support/cache/db_store.rb', line 18

def cleanup(options = {})
  @repository.where.not(expired_at: nil).update_all(deleted_at: Time.now)
end

#clear(options = {}) ⇒ Object



14
15
16
# File 'lib/active_support/cache/db_store.rb', line 14

def clear(options = {})
  @repository.update_all(deleted_at: Time.now)
end