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

Description Usage Arguments Value See Also Examples

View source: R/cache.R

Description

Make a function that takes an Rmonad and recaches it

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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)

## End(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

rmonad documentation built on March 26, 2020, 7:31 p.m.