# Set the cache
old <- cdo_cache_set(cache = "data/cache")
# Reset the cache to its previous state
cdo_cache_set(old)
# Disable the cache
old <- cdo_cache_unset()
# Again, reset the cache to its previous state.
cdo_cache_set(old)
with_cache <- function(operation, cache) {
old <- cdo_cache_set(cache)
on.exit(cdo_cache_set(old))
# Rest of the function
}
without_cache <- function(operation) {
old <- cdo_cache_unset(cache)
on.exit(cdo_cache_set(old))
# Rest of the function
}
Run the code above in your browser using DataLab