Class: ECB::Exchange::Cache
- Inherits:
-
Object
- Object
- ECB::Exchange::Cache
- Defined in:
- lib/ecb/exchange/cache.rb
Constant Summary collapse
- KEY_PREFIX =
"ecb_exchange_rates_for_date".freeze
Class Attribute Summary collapse
-
.backend ⇒ Object
Returns the value of attribute backend.
Class Method Summary collapse
- .read(key) ⇒ Object
-
.store ⇒ Object
use backend if set (must respond to read, write), otherwise Rails.cache will be used (if available) or we fall back to use an in-memory cache.
- .write(key, value) ⇒ Object
Class Attribute Details
.backend ⇒ Object
Returns the value of attribute backend.
9 10 11 |
# File 'lib/ecb/exchange/cache.rb', line 9 def backend @backend end |
Class Method Details
.read(key) ⇒ Object
16 17 18 |
# File 'lib/ecb/exchange/cache.rb', line 16 def self.read(key) store.read(cache_key(key)) end |
.store ⇒ Object
use backend if set (must respond to read, write), otherwise Rails.cache will be used (if available) or we fall back to use an in-memory cache
22 23 24 25 26 27 28 29 30 |
# File 'lib/ecb/exchange/cache.rb', line 22 def self.store if backend backend elsif defined?(Rails) && Rails.cache Rails.cache else MemoryCache.cache end end |
.write(key, value) ⇒ Object
12 13 14 |
# File 'lib/ecb/exchange/cache.rb', line 12 def self.write(key, value) store.write(cache_key(key), value) end |