cache_register: Register cache backend

Description Usage Arguments Details Value Examples

View source: R/cache_register.R

Description

Register a backend for reading and writing to the cache.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
cache_register(
  name,
  reader = get(paste0("cache_read_", name)),
  writer = get(paste0("cache_write_", name)),
  ext = name,
  ...
)

cache_backend_register(
  name,
  reader = get(paste0("cache_read_", name)),
  writer = get(paste0("cache_write_", name)),
  ext = name,
  ...
)

Arguments

name

string; name for the backend.

reader

function for reading from the cache, defaults to function cache_read_[name]

writer

function; function for writing to the cache,

ext

string; the extension used for the file type, usually everything after the final period. Defaults to name.

...

additional name/value pairs to be stored in the backend.

Details

cache_register() defines a backend for storing and retrieving data using cache. Ultimately, it associated an filename extension with functions for reading and writing cache files with that extension.

Unless you are writing a new backend, you will not need to use this function.

cache_backend_register is an alias for cache_register.

Value

The value from base::options() is returned

Examples

1
2
3
4
  ## Not run: 
    cache_register( 'csv', readr::read_csv, readr::write_csv )
  
## End(Not run)

decisionpatterns/cache documentation built on June 15, 2020, 9:35 p.m.