Class: InfoparkComponentCache::CacheStorage
- Inherits:
-
Object
- Object
- InfoparkComponentCache::CacheStorage
- Includes:
- Singleton
- Defined in:
- lib/infopark_component_cache/cache_storage.rb
Overview
Trivial wrapper around underlying cache storages. This class or any other class that inherits it must respect Rails.application.config.action_controller.perform_caching setting.
Instance Method Summary collapse
Instance Method Details
#enabled? ⇒ Boolean
26 27 28 |
# File 'lib/infopark_component_cache/cache_storage.rb', line 26 def enabled? Rails.application.config.action_controller.perform_caching end |
#exist?(key) ⇒ Boolean
13 14 15 |
# File 'lib/infopark_component_cache/cache_storage.rb', line 13 def exist?(key) enabled? && Rails.cache.exist?(key) end |
#read(key) ⇒ Object
17 18 19 |
# File 'lib/infopark_component_cache/cache_storage.rb', line 17 def read(key) Rails.cache.read(key) # you can still read the cache if you wish... end |
#write(key, value) ⇒ Object
21 22 23 |
# File 'lib/infopark_component_cache/cache_storage.rb', line 21 def write(key, value) Rails.cache.write(key, value) if enabled? end |