ropensci / rcrossref

R client for various CrossRef APIs
https://docs.ropensci.org/rcrossref
Other
165 stars 21 forks source link

Add a (single-session) cache to cr_cn #237

Closed LukasWallrich closed 1 year ago

LukasWallrich commented 1 year ago

Description

This adds an option to use a cache for cr_cn (and an approach that could easily be generalised to other request functions). The cache only persists for a single session - yet at least in my use case, that is the most relevant constraint to ensure that (e.g.) functions that fail half-way do not need to repeat requests.

It notionally adds a new dependency (rlang) but that is already required by dplyr etc anyway.

Related Issue

This does not go quite as far as #185 but might be a light-weight first step?

Example

cr_cn(dois = "10.1126/science.169.3946.635", format = "citeproc-json", cache = TRUE)

behaviour unchanged on first call, much faster from second call onward.

njahn82 commented 1 year ago

Thank you for your contribution, it looks good.