Open koheiw opened 6 years ago
There actually was once such a function in simpleCache:
https://github.com/databio/simpleCache/commit/cff17432d9aa16128914870aa57ed1c42fba964d
I removed it because I never had it 100% working and I didn't want to have non-working cruft in the release package when we submitted to CRAN.
So, I would welcome a PR with a fully functional version of that function. I have a few thoughts first about how it would work:
simpleCache
function for the actual caching part so we don't duplicate code.simpleCache
function so that it can take either an instruction
(like it does now) or a url
(which it would download)?read.table
to read in that file, but that only works for table-like files. in theory the url could be anything right? so would you pipe that through your readtext
function? in that case, we could add readtext
to the enhances
section of simpleCache
, and then throw an error if it is not installed and the user uses the url
argument?Hi @nsheff interesting to hear about the history of the package. I was thinking to use simpleCache as underlying caching function, and define a special behavior for a URL to that function makes sense. As for the file types, I had the same problem in readtext, but made the function to return path to cached file instead of file content so that appropriate IO function can be used. If it does not sound good, we could limit the supported file types to either RDS or RDA.
I had
download()
function in the readtext package, whose primary function is to save downloaded files locally as cache files to avoid downloading of the same files.However, I decided to move that function to somewhere else because the function is not specifically about textual data. The new home for the function can be a new single function package downloadCache, but, before start making the package, I want to know if you have a plan to add a similar function to simpleCache.
I am also happy to issue a PR if you think that function fits well to your package.