Class: Arturo::FeatureCaching::AllStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/arturo/feature_caching.rb

Class Method Summary collapse

Class Method Details

.expire(cache, symbol) ⇒ Object


71
72
73
# File 'lib/arturo/feature_caching.rb', line 71

def expire(cache, symbol)
  cache.delete("arturo.all")
end

.fetch(cache, symbol, &block) ⇒ Object


59
60
61
62
63
64
65
66
67
68
69
# File 'lib/arturo/feature_caching.rb', line 59

def fetch(cache, symbol, &block)
  features = cache.read("arturo.all")

  unless cache_is_current?(cache, features)
    features = Hash[Arturo::Feature.all.map { |f| [f.symbol.to_sym, f] }]
    mark_as_current!(cache)
    cache.write("arturo.all", features, :expires_in => Arturo::Feature.cache_ttl * 10)
  end

  features[symbol] || Arturo::NoSuchFeature.new(symbol)
end