KentonWhite / ProjectTemplate

A template utility for R projects that provides a skeletal project.
http://projecttemplate.net
GNU General Public License v3.0
622 stars 159 forks source link

Provide an easy way to invalidate cache #80

Closed krlmlr closed 6 years ago

krlmlr commented 10 years ago

Currently, file has to be removed manually from cache subdirectory. Can we do better?

invalidate.cache <- function(names = NULL) { ... }

Or even a config option?

krlmlr commented 10 years ago

Perhaps also an option that turns off writing to the cache?

KentonWhite commented 10 years ago

"There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton"

I know from the Rails community that we invalidate caches using hashes in the cached names based on the data content. When source data is updated, the hash is updated in a table and the cached file is compared against the hash.

I think this is the kind of solution you are wanting? Something that can detect when the source data has been updated and reload the data if an update has happened, otherwise use the cache?

krlmlr commented 10 years ago

Currently I'm fine with a manual solution that's better than deleting the cached files. More advanced stuff goes into the directions outlined in #67.

connectedblue commented 8 years ago

My proposal #152 contains a function to clear the cache of one or more objects: clear.cache(c("foo", "bar")) will delete those variables from the cache if they exist.

It provides an interface and a simple implementation behind (just deleting the correct files from the cache directory). If more advanced stuff comes along such as cache aging, maybe this interface could be extended to incorporate those?