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.
7 8 9 |
# File 'lib/ecb/exchange/cache.rb', line 7 def backend @backend end |
Class Method Details
.read(key) ⇒ Object
14 15 16 |
# File 'lib/ecb/exchange/cache.rb', line 14 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
20 21 22 23 24 25 26 27 28 |
# File 'lib/ecb/exchange/cache.rb', line 20 def self.store if backend backend elsif defined?(Rails) && Rails.cache Rails.cache else MemoryCache.cache end end |
.write(key, value) ⇒ Object
10 11 12 |
# File 'lib/ecb/exchange/cache.rb', line 10 def self.write(key, value) store.write(cache_key(key), value) end |