Class: ActiveSupport::Cache::DbCacheStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::DbCacheStore
- Defined in:
- lib/active_support/cache/db_cache_store.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
- #clear(options = nil) ⇒ Object
- #count ⇒ Object
-
#initialize(options = nil) ⇒ DbCacheStore
constructor
A new instance of DbCacheStore.
- #keys(options = {}) ⇒ Object
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( = nil) @klass = DbCache super() end |
Instance Method Details
#cleanup ⇒ Object
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(=nil) @klass.delete_all end |
#count ⇒ Object
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( = {}) .symbolize_keys! @klass.all.select {|c| !c.expired? || [:include_expires]}.collect {|c| c.key.to_sym} end |