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


99
100
101
# File 'lib/arturo/feature_caching.rb', line 99

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

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


91
92
93
94
95
96
97
# File 'lib/arturo/feature_caching.rb', line 91

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