Sha256: f64a961c5243b2029873b40fff85c0a44f95cf45c17ad2ad97bf69f5bf618f6b
Contents?: true
Size: 1.06 KB
Versions: 6
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
6 entries across 6 versions & 1 rubygems