put_eurostat_cache {restatapi} | R Documentation |
Put an object to cache
Description
Save the object (dataset/toc/DSD) to cache
Usage
put_eurostat_cache(
obj,
oname,
update_cache = FALSE,
cache_dir = NULL,
compress_file = TRUE
)
Arguments
obj |
an object (toc, dataset, DSD) |
oname |
a character string with the name of the object to reference later in the cache |
update_cache |
a logical with a default value |
cache_dir |
a path to a cache directory. The default is |
compress_file |
a logical whether to compress the RDS-file in caching. Default is |
Details
Saves a given object in cache. This can be the memory .restatapi_env
or on the hards disk. If the given cache_dir
does not exist then the file is saved in the R temp directory (tempdir()
). If the file or object with the oname
exists in the cache, then the object is not cached.
Value
The function returns the place where the object was cached: either it creates an the object in the memory ('.restatapi_env') or creates an RDS-file.
Examples
dt<-data.frame(txt=c("a","b","c"),nr=c(1,2,3))
put_eurostat_cache(dt,"teszt")
get("teszt",envir=restatapi::.restatapi_env)
put_eurostat_cache(dt,"teszt",cache_dir=tempdir())
readRDS(file.path(tempdir(),"teszt.rds"))
clean_restatapi_cache(cache_dir=tempdir())