/**
* Demo cache.
*
* Get all articles from cache table
* or load them using node_load when cache isn't set.
*
* Time example is for 50 articles.
*/
function _demo_cache() {
if(!cache_get('demo_cached_articles')) {
timer_start('Demo cache -- No cache');
$nids = db_select('node', 'n')
->fields('n', array('nid'))
->execute()->fetchCol();
$nodes = node_load_multiple($nids);
// Average is 22 ms to load 50 articles.
dpm(timer_stop('Demo cache -- No cache'));