Quick caching utility read/write functions utilizing the qs package.

write_cache(x, name = NULL, cache_dir = "cache", overwrite = TRUE)

read_cache(x, name = NULL, cache_dir = "cache")

Arguments

x

object to cache

name

name of object to read in.

cache_dir

path to cache directory.

overwrite

logical (default = TRUE)

Value

invisibly returns object passed to the function.

x

invisibly attaches object to parent global environment

See also

Examples

if (FALSE) {
mydata <- mtcars
write_cache(mydata) # will save to 'cache/mydata'.
write_cache(mydata, "mydata-v2", cache_dir = "data/temp") # will save to 'data/temp/mydata-v2'

# read back in
read_cache(mydata)
}