Class: Dato::Cache
- Inherits:
-
Object
- Object
- Dato::Cache
- Defined in:
- lib/dato/cache.rb
Class Method Summary collapse
- .active? ⇒ Boolean
- .clear! ⇒ Object
- .expires_in ⇒ Object
- .fetch(cache_key, &block) ⇒ Object
- .namespace ⇒ Object
Class Method Details
.active? ⇒ Boolean
13 14 15 |
# File 'lib/dato/cache.rb', line 13 def self.active? Dato::Config.cache.present? end |
.clear! ⇒ Object
25 26 27 |
# File 'lib/dato/cache.rb', line 25 def self.clear! Rails.cache.clear(namespace: namespace) 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 |