Class: ActiveSupport::Cache::DbCacheStore

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

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ DbCacheStore

Returns a new instance of DbCacheStore.



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

def initialize(options = nil)
  @klass = DbCache
  super(options)
end

Instance Method Details

#cleanupObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_support/cache/db_cache_store.rb', line 27

def cleanup
  l = 0
  @klass.all.each do |c|
    entry = c.entry
    if entry.expired?
      c.delete
      l += 1
    end
  end
  l
end

#clear(options = nil) ⇒ Object



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

def clear(options=nil)
  @klass.delete_all
end

#countObject



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

def count
  @klass.count
end

#keys(options = {}) ⇒ Object



22
23
24
25
# File 'lib/active_support/cache/db_cache_store.rb', line 22

def keys(options = {})
  options.symbolize_keys!
 @klass.all.select {|c| !c.expired? || options[:include_expires]}.collect {|c| c.key.to_sym}
end