Class: Caches::InMemory

Inherits:
Object
  • Object
show all
Defined in:
lib/store/caches/in_memory.rb

Instance Method Summary collapse

Constructor Details

#initializeInMemory

Returns a new instance of InMemory.



4
5
6
# File 'lib/store/caches/in_memory.rb', line 4

def initialize
  @cache = {}
end

Instance Method Details

#invalidateObject



8
9
10
# File 'lib/store/caches/in_memory.rb', line 8

def invalidate
  @cache = {}
end

#load(key) ⇒ Object



12
13
14
15
16
17
# File 'lib/store/caches/in_memory.rb', line 12

def load(key)
  data = @cache[key]
  if data
    Marshal.load(data)
  end
end

#save(key, data) ⇒ Object



19
20
21
# File 'lib/store/caches/in_memory.rb', line 19

def save key, data
  @cache[key] = Marshal.dump(data)
end