Class: ActiveSP::PersistentCache

Inherits:
Object
  • Object
show all
Defined in:
lib/activesp/persistent_caching.rb

Instance Method Summary collapse

Constructor Details

#initializePersistentCache

Returns a new instance of PersistentCache.



52
53
54
# File 'lib/activesp/persistent_caching.rb', line 52

def initialize
  @cache = {}
end

Instance Method Details

#lookup(indices) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/activesp/persistent_caching.rb', line 56

def lookup(indices)
  if o = @cache[indices]
    # puts "  Cache hit for #{indices.inspect}"
  else
    o = @cache[indices] ||= yield
    # puts "  Cache miss for #{indices.inspect}"
  end
  o
end