You are here

public function CacheTagsChecksumTrait::isValid in Drupal 8

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

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

File

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

Class

CacheTagsChecksumTrait
A trait for cache tag checksum implementations.

Namespace

Drupal\Core\Cache

Code

public function isValid($checksum, array $tags) {

  // Any cache reads in this request involving cache tags whose invalidation
  // has been delayed due to an in-progress transaction are not allowed to use
  // data stored in cache; it must be assumed to be stale. This forces those
  // results to be computed instead. Together with the logic in
  // ::getCurrentChecksum(), it also prevents that computed data from being
  // written to the cache.
  if (!empty(array_intersect($tags, $this->delayedTags))) {
    return FALSE;
  }
  return $checksum == $this
    ->calculateChecksum($tags);
}