Add a (single-session) cache to cr_cn #237
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 bydplyr
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.