Class: Djin::MemoryCache

Inherits:
Object
  • Object
show all
Defined in:
lib/djin/memory_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash_store = {}) ⇒ MemoryCache

Returns a new instance of MemoryCache.



5
6
7
# File 'lib/djin/memory_cache.rb', line 5

def initialize(hash_store = {})
  @hash_store = hash_store
end

Instance Method Details

#clearObject



13
14
15
# File 'lib/djin/memory_cache.rb', line 13

def clear
  @hash_store = {}
end

#fetch(key) ⇒ Object



9
10
11
# File 'lib/djin/memory_cache.rb', line 9

def fetch(key)
  @hash_store[key] || @hash_store[key] = yield
end