ropensci / tradestatistics

R package to access Open Trade Statistics API
https://docs.ropensci.org/tradestatistics
Apache License 2.0
76 stars 14 forks source link

Adds cache #30

Closed eliocamp closed 4 years ago

eliocamp commented 4 years ago

Addressed #29 .

The cache logic is packaged in with_cache. In memory cache is handled by memoise and file cache is done in a csvy file. I had to use data.table::fread and data.table::fwrite because it ensures (for the most part) that the object returned from the file on disk is equal to the one in memory (attributes, column classes, etc).

Let me know what you think.

eliocamp commented 4 years ago

Ups, I realised I had a bug in my implementation. I'll update momentarily.

pachadotdev commented 4 years ago

thanks a lot @eliocamp, here's the relevant part for API cache https://github.com/tradestatistics/plumber-api/blob/master/queries.R

eliocamp commented 4 years ago

Ok, now it should work.