public function CachePluginBase::generateResultsKey in Views (for Drupal 7) 8.3
Calculates and sets a cache ID used for the result cache.
Return value
string The generated cache ID.
2 calls to CachePluginBase::generateResultsKey()
- CachePluginBase::cache_get in lib/
Drupal/ views/ Plugin/ views/ cache/ CachePluginBase.php - Retrieve data from the cache.
- CachePluginBase::cache_set in lib/
Drupal/ views/ Plugin/ views/ cache/ CachePluginBase.php - Save data to the cache.
File
- lib/
Drupal/ views/ Plugin/ views/ cache/ CachePluginBase.php, line 299 - Definition of Drupal\views\Plugin\views\cache\CachePluginBase.
Class
- CachePluginBase
- The base plugin to handle caching.
Namespace
Drupal\views\Plugin\views\cacheCode
public function generateResultsKey() {
global $user;
if (!isset($this->resultsKey)) {
$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 Select) {
$query = clone $build_info[$index];
$query
->preExecute();
$build_info[$index] = (string) $query;
}
}
$key_data = array(
'build_info' => $build_info,
'roles' => array_keys($user->roles),
'super-user' => $user->uid == 1,
// special caching for super user.
'langcode' => language(LANGUAGE_TYPE_INTERFACE)->langcode,
'base_url' => $GLOBALS['base_url'],
);
foreach (array(
'exposed_info',
'page',
'sort',
'order',
'items_per_page',
'offset',
) as $key) {
if (isset($_GET[$key])) {
$key_data[$key] = $_GET[$key];
}
}
$this->resultsKey = $this->view->storage->name . ':' . $this->displayHandler->display['id'] . ':results:' . md5(serialize($key_data));
}
return $this->resultsKey;
}