You are here

public function CacheTagsChecksumTrait::getCurrentChecksum in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php \Drupal\Core\Cache\CacheTagsChecksumTrait::getCurrentChecksum()

Implements \Drupal\Core\Cache\CacheTagsChecksumInterface::getCurrentChecksum()

File

core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php, line 83

Class

CacheTagsChecksumTrait
A trait for cache tag checksum implementations.

Namespace

Drupal\Core\Cache

Code

public function getCurrentChecksum(array $tags) {

  // Any cache writes in this request containing cache tags whose invalidation
  // has been delayed due to an in-progress transaction must not be read by
  // any other request, so use a nonsensical checksum which will cause any
  // written cache items to be ignored.
  if (!empty(array_intersect($tags, $this->delayedTags))) {
    return CacheTagsChecksumInterface::INVALID_CHECKSUM_WHILE_IN_TRANSACTION;
  }

  // Remove tags that were already invalidated during this request from the
  // static caches so that another invalidation can occur later in the same
  // request. Without that, written cache items would not be invalidated
  // correctly.
  foreach ($tags as $tag) {
    unset($this->invalidatedTags[$tag]);
  }
  return $this
    ->calculateChecksum($tags);
}