Slide 6
Slide 6 text
Cache-First Logic!
function get_article (id) throw exception {
if (has_article_in_cache(id)) {
// cached data available
return get_article_from_cache(id) // fast!
} else {
// cached data unavailable,
// retrieve from network and put to cache
article = get_article_from_rest_api(id) // slow!
save_article_to_cache(id, article)
return article
}
}