1 views_plugin_cache.inc public views_plugin_cache::get_cache_key($key_data = array())

Returns cache key.

Parameters

array $key_data: Additional data for cache segmentation and/or overrides for default segmentation.

Return value

string:

File

core/modules/views/plugins/views_plugin_cache.inc, line 322
Definition of views_plugin_cache.

Class

views_plugin_cache
The base plugin to handle caching.

Code

public function get_cache_key($key_data = array()) {
  global $user;

  $key_data += array(
    'roles' => array_keys($user->roles),
    'super-user' => $user->uid == 1, // Special caching for super user.
    'language' => $GLOBALS['language']->langcode,
    'language_content' => $GLOBALS['language_content']->langcode,
    'base_url' => $GLOBALS['base_url'],
    'display_options' => $this->display->display_options,
  );

  if (empty($key_data['build_info'])) {
    $build_info = $this->view->build_info;
    foreach (array('query', 'count_query') as $index) {
      // If the default query back-end is used generate SQL query strings from
      // the query objects.
      if ($build_info[$index] instanceof SelectQueryInterface) {
        $query = $build_info[$index];

        // If the query was not yet prepared, work on a clone and run
        // preExecute().
        if (!$query->isPrepared()) {
          $query = clone $build_info[$index];
          $query->preExecute();
        }

        $key_data['build_info'][$index] = array(
          'sql' => (string) $query,
          'arguments' => $query->getArguments(),
        );
      }
    }
  }
  return md5(serialize($key_data));
}