Module: ActiveCurrency::CacheableStore
- Included in:
- RateStore
- Defined in:
- lib/active_currency/cacheable_store.rb
Overview
Mixin to add caching capability to a rate store when getting the current cache.
Instance Method Summary collapse
Instance Method Details
#add_rate(from, to, rate, date = nil) ⇒ Object
15 16 17 18 19 |
# File 'lib/active_currency/cacheable_store.rb', line 15 def add_rate(from, to, rate, date = nil) super Rails.cache.delete(cache_key(from, to)) end |
#get_rate(from, to, date = nil) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/active_currency/cacheable_store.rb', line 7 def get_rate(from, to, date = nil) return super if date Rails.cache.fetch(cache_key(from, to)) do super end end |