Class: InfoparkComponentCache::AbstractCacheStorage
- Inherits:
-
Object
- Object
- InfoparkComponentCache::AbstractCacheStorage
show all
- Includes:
- Singleton
- Defined in:
- lib/infopark_component_cache/abstract_cache_storage.rb
Overview
Note:
Any valid implementation must respect Rails.application.config.action_controller.perform_caching setting.
This abstract base class represents a very thin wrapper around the underlying cache storage.
Instance Method Summary
collapse
Instance Method Details
#enabled? ⇒ Boolean
31
32
33
|
# File 'lib/infopark_component_cache/abstract_cache_storage.rb', line 31
def enabled?
Rails.application.config.action_controller.perform_caching
end
|
#exist?(key) ⇒ Boolean
15
16
17
|
# File 'lib/infopark_component_cache/abstract_cache_storage.rb', line 15
def exist?(key)
enabled? && backing_storage.exist?(key)
end
|
#read(key) ⇒ Object
19
20
21
22
|
# File 'lib/infopark_component_cache/abstract_cache_storage.rb', line 19
def read(key)
backing_storage.read(key)
end
|
#write(key, value, options = {}) ⇒ Object
24
25
26
27
28
|
# 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
|