api_cache: Caching helper

Description Usage Arguments Examples

View source: R/caching.R

Description

Caching helper

Usage

1
api_cache(.data, dir = NULL, ...)

Arguments

.data

Result of a call to api

dir

(character) Directory to cache in. Uses rappdirs::user_cache_dir() by default

...

ignored

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
# cache
## first call is slower
api('http://localhost:5000') %>%
  api_path(get) %>%
  api_query(foo = "bar") %>%
  api_cache()

## second call is faster, pulling from cache
api('http://localhost:5000') %>%
  api_path(get) %>%
  api_query(foo = "bar") %>%
  api_cache()

# other egs
x <- api('api.crossref.org') %>%
  api_path(works) %>%
  api_query(rows = 1000) %>%
  api_cache()

## End(Not run)

sckott/request documentation built on June 22, 2020, 4:50 a.m.