You are here

function _views_fetch_data in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 8.3 includes/cache.inc \_views_fetch_data()
  2. 6.2 includes/cache.inc \_views_fetch_data()
  3. 7.3 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
cache.inc

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();
}