Class: SourceMonitor::Dashboard::Queries::Cache
- Inherits:
-
Object
- Object
- SourceMonitor::Dashboard::Queries::Cache
- Defined in:
- lib/source_monitor/dashboard/queries.rb
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
130 131 132 |
# File 'lib/source_monitor/dashboard/queries.rb', line 130 def initialize @store = {} end |
Instance Method Details
#fetch(key) ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/source_monitor/dashboard/queries.rb', line 134 def fetch(key) if store.key?(key) store.fetch(key) else store[key] = yield end end |