Class: Djin::MemoryCache
- Inherits:
-
Object
- Object
- Djin::MemoryCache
- Defined in:
- lib/djin/memory_cache.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #fetch(key) ⇒ Object
-
#initialize(hash_store = {}) ⇒ MemoryCache
constructor
A new instance of MemoryCache.
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
#clear ⇒ Object
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 |