Class: ActiveSP::PersistentCache
- Inherits:
-
Object
- Object
- ActiveSP::PersistentCache
- Defined in:
- lib/activesp/persistent_caching.rb
Instance Method Summary collapse
-
#initialize ⇒ PersistentCache
constructor
A new instance of PersistentCache.
- #lookup(indices) ⇒ Object
Constructor Details
#initialize ⇒ PersistentCache
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 |