Plugins for cache policies in the track package.

Share:

Description

Plugins for cache policies in the track package specify what objects should be keep in memory at the end of each top level command.

Usage

1
track.plugin.lru(objs, inmem, envname)

Arguments

objs

: the full object summary dataframe. A subset of this data frame is returned by track.summary(); invoke track.summary(times=3, access=3, size=T, all=T) to get the full data frame. The names of the objects are in the rownames of the dataframe.

inmem

: a logical vector with length equal to the number of rows in objs. It will have value TRUE where the corresponding object is in memory, and FALSE otherwise.

envname

: a single string containing the name of the tracking environment, in a form like <env R_GlobalEnv>.

Details

track contains an experimental feature that allows users to supply their own plugin functions that specify cache rules. Currently, the plugin function can specify whether or not an object will be flushed from memory at the end of a top-level command.

track.plugin.lru() implements a simple least-recently-used discard policy. To use is, supply it to track.options():

1

Here is another example of a very simple cache plugin function: this one keeps in memory variables whose names begin with the letter 'x'.

1
2
3
4
5
my.plugin <- function(objs, inmem, envname) {
    keep <- regexpr("^x", rownames(objs))>0
    # browser() # uncomment for debugging & development
    return(keep)
}

To use this plugin function, supply it to track.options():

1
  track.options(cacheKeepFun=my.plugin, save=TRUE)

Value

A plugin function must return a logical vector the same length as inmem, with TRUE values where the corresponding objects should be kept in memory.

Note

To flush cached tracked objects from memory, use track.flush().

Author(s)

Tony Plate tplate@acm.org