You are here

function apdqc_views_pre_render in Asynchronous Prefetch Database Query Cache 7

Implements hook_views_pre_render().

File

./apdqc.module, line 893
Asynchronous Prefetch Database Query Cache module.

Code

function apdqc_views_pre_render($view) {
  if (!function_exists('apdqc_run_prefetch_array') || !function_exists('apdqc_escape_string')) {
    return;
  }
  if (apdqc_get_bin_class_name('cache_field') !== 'APDQCache') {
    return;
  }
  $table_keys_cache_prefetch = array();
  if (isset($view->style_plugin->row_plugin->nodes)) {
    $node_types = array();
    foreach ($view->style_plugin->row_plugin->nodes as $node) {
      $node_types[$node->type] = TRUE;
    }
    if (!empty($node_types)) {
      foreach ($node_types as $type => $empty) {
        $type = apdqc_escape_string($type);
        $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle:node:' . $type;
        $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle_extra:node:' . $type;
      }
    }
  }

  // Prefetch cache.
  apdqc_run_prefetch_array($table_keys_cache_prefetch);
}