brewCache | R Documentation |
These functions provide a cache system for brew templates.
brewCache(envir=NULL)
brewCacheOn()
brewCacheOff()
setBufLen(len=0)
envir |
the |
len |
length of internal buffers for parsing the templates. |
brew can cache parsed templates for potential speedup but only when brew calls are passed filenames, not connections, and when tplParser is NULL.
brew caching is implemented by storing file names, modification
times, and the associated text and R expressions in an internal
environment. Calling brewCache()
with an appropriate
environment sets the internal cache. Calling without arguments
returns the internal cache. The cache is exposed this way mainly
for testing, debugging, performance improvement, etc. and this
may be off-limits in future releases.
Simple enough, brewCacheOn()
turns on
caching of brew templates and is equivalent to calling
brewCache(envir=new.env(hash=TRUE,parent=globalenv()))
.
brewCache()
without arguments returns the internal
environment. Calling brewCacheOff()
turns off caching by
setting the internal environment to NULL
.
One thing to note: filenames act as keys in the internal cache environment, and brew does nothing to expand them to their full paths. Thus, '/home/user/brew.html' and '~usr/brew.html' will act as separate keys, although on-disk they may actually point to the same file.
setBufLen()
initializes internal parsing vectors to length len
. Default is 0.
brewCache()
without arguments returns the internal cache. All others invisibly return NULL
.
Jeffrey Horner <jeff.horner@vanderbilt.edu>
Sweave
for the original report generator.
## Turn on caching
brewCacheOn()
## Brew a template
brew(system.file("featurefull.brew",package="brew"),envir=new.env())
## Get the internal cache
cache <- brewCache()
## Inspect
as.list(cache)
## Inspect first file cached in list
as.list(cache)[[1]]
## Inspect environment that contains text and parsed code
as.list(as.list(cache)[[1]]$env)
## Turn off brew caching
brewCacheOff()
rm(cache)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.