if (FALSE) {
# demo function to cache within
shorten_url_cache <- function(url){
body = list(longUrl = url)
f <- gar_api_generator("https://www.googleapis.com/urlshortener/v1/url",
"POST",
data_parse_function = function(x) x)
f(the_body = body)
}
## only cache if this URL
gar_cache_setup(invalid_func = function(req){
req$content$longUrl == "http://code.markedmondson.me/"
})
# authentication
gar_auth()
## caches
shorten_url_cache("http://code.markedmondson.me")
## read cache
shorten_url("http://code.markedmondson.me")
## ..but dont cache me
shorten_url_cache("http://blahblah.com")
}
Run the code above in your browser using DataLab