storeCache.RdSometimes you use significant computational power to create an object, but
you didn't cache it with simpleCache. Oops, maybe you wish you had, after the
fact. This function lets you store an object in the environment so it could
be loaded by future calls to simpleCache.
storeCache(cacheName, cacheDir = getCacheDir(), cacheSubDir = NULL, recreate = FALSE)
| cacheName | Unique name for the cache (and R object to be cached). |
|---|---|
| cacheDir | The directory where caches are saved (and loaded from).
Defaults to the global |
| cacheSubDir | You can specify a subdirectory within the cacheDir
variable. Defaults to |
| recreate | Forces reconstruction of the cache |
This can be used in interactive sessions, but could also be used for another
use case: you have a complicated set of instructions (too much to pass as the
instruction argument to simpleCache), so you could just stick a call to
storeCache at the end.
#> [1] "/tmp/RtmpnwNyJo"setCacheDir(cacheDir) # build some caches simpleCache("normSample", { rnorm(5e3, 0,1) }, recreate=TRUE, timer=TRUE)#>#>#>#>#>#> NULL# what's available? listCaches()#> [1] "normSample.RData"#>#>#>#> Error in doTryCatch(return(expr), name, parentenv, handler): ::Error:: If you do not provide an instruction argument, you must setglobal option RBUILD.DIR with setCacheBuildDir, or specify a buildDirparameter directly to simpleCache().