function CacheTagsChecksumDecorator::isValid

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/performance_test/src/Cache/CacheTagsChecksumDecorator.php \Drupal\performance_test\Cache\CacheTagsChecksumDecorator::isValid()

Returns whether the checksum is valid for the given cache tags.

Used when retrieving a cache item in a cache backend, to verify that no cache tag based invalidation happened.

Parameters

int $checksum: The checksum that was stored together with the cache item.

string[] $tags: The cache tags that were stored together with the cache item.

Return value

bool FALSE if cache tag invalidations happened for the passed in tags since the cache item was stored, TRUE otherwise.

Overrides CacheTagsChecksumInterface::isValid

File

core/modules/system/tests/modules/performance_test/src/Cache/CacheTagsChecksumDecorator.php, line 38

Class

CacheTagsChecksumDecorator
Wraps an existing cache tags checksum invalidator to track calls separately.

Namespace

Drupal\performance_test\Cache

Code

public function isValid($checksum, array $tags) {
  // If there are no cache tags, the cache item is always valid, and the child
  // method will be a no-op, so don't log anything.
  if (empty($tags)) {
    return $this->checksumInvalidator
      ->isValid($checksum, $tags);
  }
  $start = microtime(TRUE);
  $return = $this->checksumInvalidator
    ->isValid($checksum, $tags);
  $stop = microtime(TRUE);
  $this->logCacheTagOperation($tags, $start, $stop, CacheTagOperation::IsValid);
  return $return;
}

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