Class: Syro::Tilt::Cache::MemoryStore
- Inherits:
-
Object
- Object
- Syro::Tilt::Cache::MemoryStore
- Defined in:
- lib/syro/tilt/cache.rb
Overview
A very thin wrapper around Hash, with a Mutex.
Instance Method Summary collapse
- #fetch(*key) ⇒ Object
-
#initialize ⇒ MemoryStore
constructor
A new instance of MemoryStore.
Constructor Details
#initialize ⇒ MemoryStore
Returns a new instance of MemoryStore.
10 11 12 13 |
# File 'lib/syro/tilt/cache.rb', line 10 def initialize @cache = {} @mutex = Mutex.new end |
Instance Method Details
#fetch(*key) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/syro/tilt/cache.rb', line 15 def fetch(*key) @mutex.synchronize do @cache.fetch(key) do @cache[key] = yield end end end |