json-vat
json-vat copied to clipboard
Reset memoized rates when refreshing JSONVAT cache
When calling JSONVAT.cache
the rates collection isn't affected as it is memoized inside the rates
method and JSONVAT serves old data. I've added reset_rates
which allows manual cleanup of memoized rates and it is also called from inside the cache
method.
However this won't work anyway if cache is refreshed in other process (e.g. via scheduled rake task). So some sort of cache id or lock is needed so JSONVAT in other process can see that its rates collection is outdated. The most simplistic candidate is file timestamp in case of file cache. Other candidate is the version ID but in this case the jsonvat file needs to be parsed during each check. Third candidate could be file checksum.