brewCache {brew}R Documentation

Caching Brew Templates

Description

These functions provide a cache system for brew templates.

Usage

brewCache(envir=NULL)

brewCacheOn()
brewCacheOff()

setBufLen(len=0)

Arguments

envir

the environment to store text and R expressions for each brewed template.

len

length of internal buffers for parsing the templates.

Details

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.

Value

brewCache() without arguments returns the internal cache. All others invisibly return NULL.

Author(s)

Jeffrey Horner <jeff.horner@vanderbilt.edu>

See Also

Sweave for the original report generator.

Examples


## 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)

[Package brew version 1.0-10 Index]