Class: SimpleCache
- Inherits:
-
Object
- Object
- SimpleCache
- Defined in:
- lib/simple_cache.rb
Direct Known Subclasses
AnalyticDBConnectionPool, RedshiftConnectionPool, Schemas::Descriptors
Instance Method Summary collapse
- #bust ⇒ Object
- #get(key) ⇒ Object
-
#initialize ⇒ SimpleCache
constructor
A new instance of SimpleCache.
Constructor Details
#initialize ⇒ SimpleCache
Returns a new instance of SimpleCache.
2 3 4 |
# File 'lib/simple_cache.rb', line 2 def initialize @cache = {} end |
Instance Method Details
#bust ⇒ Object
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 |