function VariationCache::invalidate

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

Marks a cache item as invalid.

To stay consistent with ::get(), this only affects the active variation, not all possible variations for the associated cache contexts.

Parameters

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

\Drupal\Core\Cache\CacheableDependencyInterface $initial_cacheability: The cache metadata of the data to store before other systems had a chance to adjust it. This is also commonly known as "pre-bubbling" cacheability.

Overrides VariationCacheInterface::invalidate

File

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

Class

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

Namespace

Drupal\Core\Cache

Code

public function invalidate(array $keys, CacheableDependencyInterface $initial_cacheability) : void {
  $chain = $this->getRedirectChain($keys, $initial_cacheability);
  $this->cacheBackend
    ->invalidate(array_key_last($chain));
}

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