json-vat icon indicating copy to clipboard operation
json-vat copied to clipboard

Reset memoized rates when refreshing JSONVAT cache

Open wojtha opened this issue 8 years ago • 1 comments

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.

wojtha avatar Aug 30 '16 15:08 wojtha

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.

wojtha avatar Aug 30 '16 16:08 wojtha