Returns a new connection object with caching enabled. Cached responses are stored as JSON files in the specified directory, keyed by URL and query parameters.
Arguments
- con
A
brapi_connection()object.- dir
Character. Directory to store cached responses. Defaults to a user cache directory via
rappdirs::user_cache_dir().- ttl
Numeric. Time-to-live for cached entries in seconds. Default 3600 (1 hour).
Examples
con <- brapi_connection("https://test-server.brapi.org")
con <- brapi_cache_enable(con, dir = tempdir(), ttl = 7200)
#> ✔ Caching enabled at /tmp/Rtmpb9eCNO (TTL: 7200s)
con
#>
#> ── BrAPI Connection
#> • Server: <https://test-server.brapi.org>
#> • Version: v2
#> • Auth: ✗ no token
#> • Page size: 1000
#> • Timeout: 120s
#> • Cache: enabled (/tmp/Rtmpb9eCNO)
