function VariationCache::createCacheId
Same name in other branches
- 11.x core/lib/Drupal/Core/Cache/VariationCache.php \Drupal\Core\Cache\VariationCache::createCacheId()
Creates a cache ID based on cache keys and cacheable metadata.
If cache contexts are optimized during the creating of the cache ID, then the effect of said optimization on the cache contexts will be reflected in the provided cacheable metadata.
Parameters
string[] $keys: The cache keys of the data to store.
\Drupal\Core\Cache\CacheableMetadata $cacheable_metadata: The cacheable metadata of the data to store.
Return value
string The cache ID.
1 call to VariationCache::createCacheId()
- VariationCache::set in core/
lib/ Drupal/ Core/ Cache/ VariationCache.php
File
-
core/
lib/ Drupal/ Core/ Cache/ VariationCache.php, line 217
Class
- VariationCache
- Wraps a regular cache backend to make it support cache contexts.
Namespace
Drupal\Core\CacheCode
protected function createCacheId(array $keys, CacheableMetadata &$cacheable_metadata) {
if ($contexts = $cacheable_metadata->getCacheContexts()) {
$context_cache_keys = $this->cacheContextsManager
->convertTokensToKeys($contexts);
$keys = array_merge($keys, $context_cache_keys->getKeys());
$cacheable_metadata = $cacheable_metadata->merge($context_cache_keys);
}
return implode(':', $keys);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.