function _views_fetch_data

Same name in other branches
  1. 7.x-3.x includes/cache.inc \_views_fetch_data()

Fetch Views' data from the cache

1 call to _views_fetch_data()
views_fetch_data in ./views.module
Fetch Views' data from the cache

File

includes/cache.inc, line 26

Code

function _views_fetch_data($table = NULL, $reset = FALSE) {
    static $cache = NULL;
    if (!isset($cache) || $reset) {
        $start = views_microtime();
        // NOTE: This happens whether we retrieve them from cache or otherwise.
        views_include_handlers();
        $data = views_cache_get('views_data', TRUE);
        if (!empty($data->data)) {
            $cache = $data->data;
        }
        if (empty($cache)) {
            $cache = module_invoke_all('views_data');
            foreach (module_implements('views_data_alter') as $module) {
                $function = $module . '_views_data_alter';
                $function($cache);
            }
            views_cache_set('views_data', $cache, TRUE);
        }
        vpr('Views data build time: ' . (views_microtime() - $start) * 1000 . ' ms');
    }
    if (!$table) {
        return $cache;
    }
    if (isset($cache[$table])) {
        return $cache[$table];
    }
    // Return an empty array if there is no match.
    return array();
}