Skip to content

Register a serialization format which can be used for madrat cache files via setConfig(cacheformat = ...). The formats "rds" (the default) and "qs2" are always available, "qs2" requires the qs2 package.

Usage

registerCacheFormat(
  name,
  write,
  read,
  extension = name,
  toRds = NULL,
  packages = NULL
)

cacheFormats()

Arguments

name

Name of the format, e.g. "qs2".

write

A function(x, file) writing object x to file.

read

A function(file) returning the object stored in file.

extension

File extension used for cache files of this format (without leading dot). Defaults to name.

toRds

Optional fast path conversion function(input, output) converting a cache file of this format to a rds file. This is used when bundling puc files, which always contain rds files.

packages

Names of packages which must be installed for this format, e.g. "qs2". Checked, so that a missing package is reported immediately.

Value

Invisibly, the registered format definition.

Details

Cache files are identified by their file extension, so each format must use a distinct one. Extensions are restricted to alphanumeric characters.

Functions

  • cacheFormats(): names of all currently registered cache formats

See also

setConfig, cacheFormats

Other cache management: cacheCleanup(), cacheCopy()

Author

Patrick Rein

Examples

if (FALSE) { # \dontrun{
registerCacheFormat("qs", write = qs::qsave, read = qs::qread, packages = "qs")
setConfig(cacheformat = "qs")
} # }