Module: ActiveCurrency::CacheableStore
- Includes:
- AfterCommitEverywhere
- 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
17 18 19 20 21 22 23 |
# File 'lib/active_currency/cacheable_store.rb', line 17 def add_rate(from, to, rate, date = nil) super after_commit do Rails.cache.delete(cache_key(from, to)) end end |
#get_rate(from, to, date = nil) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/active_currency/cacheable_store.rb', line 9 def get_rate(from, to, date = nil) return super if date Rails.cache.fetch(cache_key(from, to)) do super end end |