Class: Web::MemoryCache

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

Instance Method Summary collapse

Constructor Details

#initializeMemoryCache

Returns a new instance of MemoryCache.



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

def initialize
  @hash = {}
end

Instance Method Details

#get(key) ⇒ Object



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

def get(key)
  @hash[key]
end

#set(key, value, expires = nil) ⇒ Object



13
14
15
16
# File 'lib/web/cache/memory_cache.rb', line 13

def set(key, value, expires = nil)
  raise 'MemoryCache does not support key expiration' if expires
  @hash[key] = value
end