Sharing caches across projects

By default, simpleCache will store its caches for your project in the RCACHE.DIR global option. This is designed to be a project-specific directory, so I have a different RCache dir for each of my projects. Sometimes, though, I want to share caches across projects, and so it's useful to have a definition of a shared cache directory. I think of this as a general resource. For instance, I use this to store the location of all CpGs in the human genome, which I use repeatedly in many projects.

To solve this problem, simpleCache uses a second global option, SHARE.RCACHE.DIR, which you can access with the convenience setter setSharedCacheDir(). Then, you use simpleCache as normal but with the additional parameter of cacheDir, or the convenience alias simpleCacheShared(), as outlined below:

library(simpleCache)
cacheDir = tempdir()
setSharedCacheDir(cacheDir)
simpleCacheShared("normSample", { rnorm(1e7, 0,1) }, recreate=TRUE)
simpleCacheShared("normSample", { rnorm(1e7, 0,1) })
deleteCaches("normSample", force=TRUE)


nsheff/simpleCache documentation built on April 24, 2021, 1:38 a.m.