Class: Arturo::FeatureCaching::OneStrategy

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

Class Method Summary collapse

Class Method Details

.expire(cache, symbol) ⇒ Object



191
192
193
# File 'lib/arturo/feature_caching.rb', line 191

def self.expire(cache, symbol)
  cache.delete("arturo.#{symbol}")
end

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



183
184
185
186
187
188
189
# File 'lib/arturo/feature_caching.rb', line 183

def self.fetch(cache, symbol, &block)
  if feature = cache.read("arturo.#{symbol}")
    feature
  else
    cache.write("arturo.#{symbol}", yield || Arturo::NoSuchFeature.new(symbol), expires_in: Arturo::Feature.cache_ttl)
  end
end