class ActiveSupport::Cache::DbCacheStore
Public Class Methods
new(options = nil)
click to toggle source
Calls superclass method
# File lib/active_support/cache/db_cache_store.rb, line 9 def initialize(options = nil) @klass = DbCache super(options) end
Public Instance Methods
cleanup()
click to toggle source
# 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)
click to toggle source
# File lib/active_support/cache/db_cache_store.rb, line 14 def clear(options=nil) @klass.delete_all end
count()
click to toggle source
# File lib/active_support/cache/db_cache_store.rb, line 18 def count @klass.count end
keys(options = {})
click to toggle source
# 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
Protected Instance Methods
delete_entry(key, options)
click to toggle source
# File lib/active_support/cache/db_cache_store.rb, line 60 def delete_entry(key, options) data = @klass.find_by_key(key) if data data.delete else false end end
read_entry(key, options)
click to toggle source
# File lib/active_support/cache/db_cache_store.rb, line 47 def read_entry(key, options) data = @klass.find_by_key(key) entry = nil unless data.nil? entry = data.entry if entry.expired? data.delete entry = nil end end entry end
write_entry(key, entry, options)
click to toggle source
# File lib/active_support/cache/db_cache_store.rb, line 41 def write_entry(key, entry, options) data = @klass.find_or_create_by_key(key) data.value = entry data.save end