class InfoparkComponentCache::AbstractCacheStorage
@author Tomasz Przedmojski <tomasz.przedmojski@infopark.de>
This abstract base class represents a very thin wrapper around the underlying cache storage.
@note Any valid implementation must respect
Rails.application.config.action_controller.perform_caching setting.
Public Instance Methods
enabled?()
click to toggle source
@private
# File lib/infopark_component_cache/abstract_cache_storage.rb, line 31 def enabled? Rails.application.config.action_controller.perform_caching end
exist?(key)
click to toggle source
# File lib/infopark_component_cache/abstract_cache_storage.rb, line 15 def exist?(key) enabled? && backing_storage.exist?(key) end
read(key)
click to toggle source
# File lib/infopark_component_cache/abstract_cache_storage.rb, line 19 def read(key) # it is possible to read disabled cache! backing_storage.read(key) end
write(key, value, options = {})
click to toggle source
# File lib/infopark_component_cache/abstract_cache_storage.rb, line 24 def write(key, value, options = {}) backing_storage.write(key, value, options) if enabled? rescue Errno::ENOSPC => e Rails.logger.error("Unable to write cache, cache full: #{e.message}") end
Protected Instance Methods
backing_storage()
click to toggle source
# File lib/infopark_component_cache/abstract_cache_storage.rb, line 37 def backing_storage raise TypeError, "Cannot use abstract cache storage. Please provide a concrete cache storage in #{self.class.name}" end