public function CachePluginBase::generateResultsKey in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/views/cache/CachePluginBase.php \Drupal\views\Plugin\views\cache\CachePluginBase::generateResultsKey()
Calculates and sets a cache ID used for the result cache.
Return value
string The generated cache ID.
2 calls to CachePluginBase::generateResultsKey()
- CachePluginBase::cacheGet in core/
modules/ views/ src/ Plugin/ views/ cache/ CachePluginBase.php - Retrieve data from the cache.
- CachePluginBase::cacheSet in core/
modules/ views/ src/ Plugin/ views/ cache/ CachePluginBase.php - Save data to the cache.
File
- core/
modules/ views/ src/ Plugin/ views/ cache/ CachePluginBase.php, line 187 - Contains \Drupal\views\Plugin\views\cache\CachePluginBase.
Class
- CachePluginBase
- The base plugin to handle caching.
Namespace
Drupal\views\Plugin\views\cacheCode
public function generateResultsKey() {
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] = array(
'query' => (string) $query,
'arguments' => $query
->getArguments(),
);
}
}
$key_data = [
'build_info' => $build_info,
];
// @todo https://www.drupal.org/node/2433591 might solve it to not require
// the pager information here.
$key_data['pager'] = [
'page' => $this->view
->getCurrentPage(),
'items_per_page' => $this->view
->getItemsPerPage(),
'offset' => $this->view
->getOffset(),
];
$key_data += \Drupal::service('cache_contexts_manager')
->convertTokensToKeys($this->displayHandler
->getCacheMetadata()
->getCacheContexts())
->getKeys();
$this->resultsKey = $this->view->storage
->id() . ':' . $this->displayHandler->display['id'] . ':results:' . hash('sha256', serialize($key_data));
}
return $this->resultsKey;
}