Sha256: 7bec42402e6f7cc139f03bd96b09303c49fa5c7c43bc6da9cf9f5aa10f903433
Contents?: true
Size: 1.06 KB
Versions: 5
Compression:
Stored size: 1.06 KB
Contents
require 'singleton' module InfoparkComponentCache # @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. class AbstractCacheStorage include Singleton def exist?(key) enabled? && backing_storage.exist?(key) end def read(key) # it is possible to read disabled cache! backing_storage.read(key) end 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 # @private def enabled? Rails.application.config.action_controller.perform_caching end protected def backing_storage raise TypeError, "Cannot use abstract cache storage. Please provide a concrete cache storage in #{self.class.name}" end end end
Version data entries
5 entries across 5 versions & 1 rubygems