Class: Exchange::Cache::Memory
- Defined in:
- lib/exchange/cache/memory.rb
Overview
A class that uses instance variables on the cache singleton class to store values in memory
Instance Method Summary collapse
-
#cached(api, opts = {}) { ... } ⇒ Object
returns either cached data from an instance variable or calls the block and caches it in an instance variable.
Instance Method Details
#cached(api, opts = {}) { ... } ⇒ Object
returns either cached data from an instance variable or calls the block and caches it in an instance variable. This method has to be the same in all the cache classes in order for the configuration binding to work
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/exchange/cache/memory.rb', line 24 def cached api, opts={}, &block ivar_name = instance_variable_name(api, opts) result = instance_variable_get(ivar_name) unless result && !result.to_s.empty? result = super if result && !result.to_s.empty? instance_variable_set(ivar_name, result) end clean! end opts[:plain] ? result.cachify : result end |