Module: CcyConvertor::RateCache
- Included in:
- RateProvider
- Defined in:
- lib/ccy_convertor/rate_cache.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#cache_duration ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/ccy_convertor/rate_cache.rb', line 10 def cache_duration @cache_duration ||= if cache_duration_nil? 0 else CcyConvertor.configuration.cache_duration[rate_provider_name] end end |
Instance Method Details
#cache ⇒ Object
5 6 7 8 |
# File 'lib/ccy_convertor/rate_cache.rb', line 5 def cache @cache ||= {} @cache[rate_provider_name] ||= ActiveSupport::Cache::MemoryStore.new(expires_in: cache_duration) end |
#cache_duration_nil? ⇒ Boolean
18 19 20 21 22 |
# File 'lib/ccy_convertor/rate_cache.rb', line 18 def cache_duration_nil? @cache_duration.nil? && (CcyConvertor.configuration.cache_duration.nil? || CcyConvertor.configuration.cache_duration[rate_provider_name].nil?) end |
#cache_key(request_url) ⇒ Object
24 25 26 |
# File 'lib/ccy_convertor/rate_cache.rb', line 24 def cache_key(request_url) Digest::SHA2.hexdigest request_url end |