Class: Web::MemoryCache
- Inherits:
-
Object
- Object
- Web::MemoryCache
- Defined in:
- lib/web/cache/memory_cache.rb
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize ⇒ MemoryCache
constructor
A new instance of MemoryCache.
- #set(key, value, expires = nil) ⇒ Object
Constructor Details
#initialize ⇒ MemoryCache
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 |