function VariationCache::createCacheId
Same name in other branches
- 10 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 - Stores data in the cache.
File
-
core/
lib/ Drupal/ Core/ Cache/ VariationCache.php, line 260
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.