Description Usage Arguments Details Value
Assign a value to a name in an environment with cache mechanism.
1 2 3 4 5 | cachedAssign(x, value, force = FALSE)
loadCache(x, force = FALSE)
cacheExists(x)
|
x |
a variable name, given as a character string. |
value |
a value to be assigned to ‘x’. |
force |
force to overwrite or load from the cache file. |
When it is the first time to assign some variable with 'cachedAssign()', expression of 'value' will be evaluated, saved to cache file, and then assigned to variable 'x'. After that, as the cache file exists, evaluation of 'value' will be skipped, and value stored in cache file will be loaded and assigned to 'x' instead.
Cache files are stored in cache directory, as the same name as the varaibles, with extension name '.rds'. By default, the cache directory is set to 'cached/', that means variable 'foo' will be stored as cache file 'cached/foo.rds'. The cache directory can be configured by 'option("cache.directory")'
'loadCache()' just loads value from existed cache file, and it will fail when cache file does not exist.
'cacheExists()' is for checking if a variable has been cached.
like 'assign()' in 'base' package, this function is invoked for its side effect, which is assigning 'value' to the variable 'x'.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.