function VariationCache::createCacheIdFast

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Cache/VariationCache.php \Drupal\Core\Cache\VariationCache::createCacheIdFast()

Creates a cache ID based on cache keys and cacheable metadata.

This is a simpler, faster version of ::createCacheID() to be used when you do not care about how cache context optimization affects the cache tags.

Parameters

string[] $keys: The cache keys of the data to store.

\Drupal\Core\Cache\CacheableDependencyInterface $cacheability: The cache metadata of the data to store.

Return value

string The cache ID for the redirect.

2 calls to VariationCache::createCacheIdFast()
VariationCache::getRedirectChain in core/lib/Drupal/Core/Cache/VariationCache.php
Performs a full get, returning every step of the way.
VariationCache::set in core/lib/Drupal/Core/Cache/VariationCache.php

File

core/lib/Drupal/Core/Cache/VariationCache.php, line 240

Class

VariationCache
Wraps a regular cache backend to make it support cache contexts.

Namespace

Drupal\Core\Cache

Code

protected function createCacheIdFast(array $keys, CacheableDependencyInterface $cacheability) {
    if ($contexts = $cacheability->getCacheContexts()) {
        $context_cache_keys = $this->cacheContextsManager
            ->convertTokensToKeys($contexts);
        $keys = array_merge($keys, $context_cache_keys->getKeys());
    }
    return implode(':', $keys);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.