Description Usage Arguments Examples
Example function with caching.
1 |
doi |
Logical |
key |
API key |
cache |
Logical, defaults to FALSE |
backend |
One of local, redis, couchdb, mongodb, sqlite. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Get some DOIs via rplos
dois <- searchplos(terms="*:*", fields='id', toquery='doc_type:full', limit=25)
dois <- do.call(c, dois[,1])
# Using local storage
foo(doi = dois, apikey="WQcDSXml2VSWx3P")
# Using local storage, the default, 1st run with cache=TRUE same as cache=FALSE, then 2nd time faster
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P", cache=FALSE) )
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P", cache=TRUE) )
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P", cache=TRUE) )
# Using redis, redis should be a little bit faster
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P") )
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P", cache=TRUE, backend="sqlite") )
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P", cache=TRUE, backend="sqlite") )
# Using sqlite, quite a bit slower than local and redis
dbCreate("mydb", type = "SQLite")
db <- dbInit("mydb", type = "SQLite")
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P") )
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P", cache=TRUE, backend="sqlite") )
system.time( foo(doi = dois, apikey="WQcDSXml2VSWx3P", cache=TRUE, backend="sqlite") )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.