Class: SimpleCache

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_cache.rb

Instance Method Summary collapse

Constructor Details

#initializeSimpleCache

Returns a new instance of SimpleCache.



2
3
4
# File 'lib/simple_cache.rb', line 2

def initialize
  @cache = {}
end

Instance Method Details

#bustObject



10
11
12
# File 'lib/simple_cache.rb', line 10

def bust
  @cache.clear
end

#get(key) ⇒ Object



6
7
8
# File 'lib/simple_cache.rb', line 6

def get(key)
  @cache.key?(key) ? @cache[key] : @cache[key] = new_object(key)
end