Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. VariationCache.php

function 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 261

Class

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

Namespace

Drupal\Core\Cache

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal