Class: Syro::Tilt::Cache::MemoryStore

Inherits:
Object
  • Object
show all
Defined in:
lib/syro/tilt/cache.rb

Overview

A very thin wrapper around Hash, with a Mutex.

Instance Method Summary collapse

Constructor Details

#initializeMemoryStore

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