Class: Dato::Cache
- Inherits:
-
Object
- Object
- Dato::Cache
- Defined in:
- lib/dato/cache.rb
Class Method Summary collapse
Class Method Details
.active? ⇒ Boolean
13 14 15 |
# File 'lib/dato/cache.rb', line 13 def self.active? Dato::Config.cache.present? end |
.expires_in ⇒ Object
17 18 19 |
# File 'lib/dato/cache.rb', line 17 def self.expires_in Dato::Config.cache.is_a?(Integer) ? Dato::Config.cache : 60.minutes end |
.fetch(cache_key, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/dato/cache.rb', line 3 def self.fetch(cache_key, &block) if active? Rails.cache.fetch(cache_key, expires_in: expires_in, namespace: namespace) do block.call end else block.call end end |