Learn R Programming

rmonad (version 0.7.0)

make_recacher: Make a function that takes an Rmonad and recaches it

Description

Make a function that takes an Rmonad and recaches it

Usage

make_recacher(cacher, preserve = TRUE)

Arguments

cacher

A function of a data value

preserve

logical Should the cached value be preserved across bind operations?

Value

A function that swaps the cache function of an Rmonad

See Also

Other cache: clear_cache, fail_cache, make_cacher, memory_cache, no_cache, void_cache

Examples

Run this code
# NOT RUN {
  recacher <- make_recacher(make_local_cacher())
  m <- iris %>>% summary %>% recacher
  # load the data from a local file
  .single_value(m)

  recacher <- make_recacher(memory_cache)
  m <- iris %>>% summary %>% recacher
  # load the data from memory
  .single_value(m)
# }
# NOT RUN {
add1 <- function(x) x+1
add2 <- function(x) x+2
add3 <- function(x) x+3
cc <- make_recacher(make_local_cacher())
3 %>>% add1 %>% cc %>>% add2 %>>% add3 -> m
m
# }

Run the code above in your browser using DataLab