Class: Arturo::FeatureCaching::AllStrategy
- Inherits:
-
Object
- Object
- Arturo::FeatureCaching::AllStrategy
- Defined in:
- lib/arturo/feature_caching.rb
Class Method Summary collapse
- .expire(cache, symbol) ⇒ Object
- .fetch(cache, symbol, &block) ⇒ Arturo::Feature, Arturo::NoSuchFeature
- .register_cache_update_listener(&block) ⇒ Object
Class Method Details
.expire(cache, symbol) ⇒ Object
84 85 86 |
# File 'lib/arturo/feature_caching.rb', line 84 def expire(cache, symbol) cache.delete("arturo.all") end |
.fetch(cache, symbol, &block) ⇒ Arturo::Feature, Arturo::NoSuchFeature
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/arturo/feature_caching.rb', line 70 def fetch(cache, symbol, &block) existing_features = cache.read("arturo.all") features = if cache_is_current?(cache, existing_features) existing_features else arturos_from_origin(fallback: existing_features).tap do |updated_features| update_and_extend_cache!(cache, updated_features) end end features[symbol] || Arturo::NoSuchFeature.new(symbol) end |
.register_cache_update_listener(&block) ⇒ Object
88 89 90 |
# File 'lib/arturo/feature_caching.rb', line 88 def register_cache_update_listener(&block) cache_update_listeners << block end |