Description Usage Arguments Details See Also Examples
Caches or uncaches and object in a cache directory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | cache(
object,
name = deparse(substitute(object)),
cache = cache_path(),
...,
overwrite = getOption("cache.overwrite", TRUE),
envir = parent.frame(),
backend = cache_backend()
)
cache_write(
object,
name,
cache = cache_path(),
...,
overwrite = getOption("cache.overwrite", TRUE),
envir = parent.frame(),
backend = cache_backend()
)
uncache(
name,
...,
envir = parent.frame(),
overwrite = getOption("uncache.overwrite", TRUE),
reader = cache_reader()
)
cache_read(name, cache = cache_path(), ..., reader = name_to_reader(name))
uncache_(...)
|
object |
object to cache |
name |
string; name for the object defaults to the
|
cache |
string; path to cache directory. The default is
|
... |
additional arguments |
overwrite |
logical; whether to overwrite if it |
envir |
environment .. where object to cache or to where object should
be uncached. Defaults to the |
backend |
string; (name of) the backend used.
dispatching to The
The writing of files is delegated to |
reader |
function for reading from the cache. Defaults to |
cache_write
is like cache
but takes a name of an object and an
environment. It is mainly useful for programatic writing to the cache.
cache_write
will not work unless a cache direcort has been defined. See
cache_path()
.
uncache
restores an object from disk. It restores based on the name. It
looks in the cache
cache_read()
is a functional, no side-affect version of uncache
. It
reads and returns the object. Given a name, cache_read()
will:
read the object with the default backend/extension warning if there are any alternate files.
read alternate (non-default) files with backends/extensions
alert and matching but unsupported files.
cache_all()
for saving all objects to the cache.
base::saveRDS()
cache_path()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
data(mtcars)
cache(mtcars) # cache/mtcars.rds
# cache( mtcars, "mycache" ) # mycache/mtcars.rds
# cache( mtcars, "mycache", Sys.Date ) # mycache/mtcars-YYYY-MM-DD.rds
# EXPLICIT USE OF timestamp
# options( timestamp = Sys.Date )
# cache( mtcars, "mycache" ) # mycache/mtcars-YYYY-MM-DD.rds
uncache(mtcars)
# uncache_("mtcars")
cache_use_rds()
cache(mtcars)
if( exists('mtcars') ) rm(mtcars)
uncache(mtcars)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.