Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable caching #406

Open
lpiep opened this issue Feb 9, 2022 · 5 comments
Open

Option to disable caching #406

lpiep opened this issue Feb 9, 2022 · 5 comments

Comments

@lpiep
Copy link

lpiep commented Feb 9, 2022

For data retrieval functions such as lcd, isd, etc, it would be helpful to include an option not to cache a cleaned version of the data, rather than having to delete the cached files manually with lcd_cache$delete and similar functions. The isd function has a cleanup option already, although this only removes the raw .gz files.

My use case is that I'm using rnoaa to periodically download and process LCD data, and I want to always be getting the data as it appears on NOAA's servers.

Let me know if this seems like a reasonable feature request. Happy to help with implementation.

@sckott
Copy link
Contributor

sckott commented Feb 10, 2022

@lpiep
Copy link
Author

lpiep commented Feb 10, 2022

Thanks @sckott, I did read through that. I see I can clear the cache when I'm done (e.g. with lcd_cache$delete_all(), but it's not obvious to me how to disable caching entirely. That is, prevent cache files from being stored in the home directory at all.

@sckott
Copy link
Contributor

sckott commented Feb 10, 2022

force=TRUE ?

@lpiep
Copy link
Author

lpiep commented Feb 11, 2022

For lcd, at least, there isn't a force option documented, and using it doesn't appear to prevent the cache file from being used.

> rnoaa::lcd_cache$delete_all()
> x <- rnoaa::lcd('72027763843', 2022)
> x2 <- rnoaa::lcd('72027763843', 2022, force = TRUE)
using cached file: ~/.cache/R/noaa_lcd/2022_72027763843.csv
date created (size, mb): 2022-02-11 04:59:29 (1.705)

Even on isd, which does have aforce argument, it doesn't stop the rds file from being saved to the cache, it only prevents it from being used.

> rnoaa::isd_cache$delete_all()
> x <- rnoaa::isd('720277', '63843', 2022, force = TRUE)
<path>~/.cache/R/noaa_isd/720277-63843-2022.gz

> list.files(rnoaa::isd_cache$cache_path_get())
[1] "720277-63843-2022.rds"

I suppose that in either case, explicitly clearing the cache after downloading is sufficient for my purposes. I thought though that it would be nice to have finer control over what rnoaa saves into the home directory, especially when the user specifies not to use those files.

@sckott
Copy link
Contributor

sckott commented Feb 11, 2022

@djhocking i'll let you take it from here, just tried to chime in while i had a few min (@lpiep i'm the former maintainer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants