You are here

public function TimestampCacheTagsChecksum::isValid in Memcache API and Integration 8.2

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

src/Cache/TimestampCacheTagsChecksum.php, line 84

Class

TimestampCacheTagsChecksum
Cache tags invalidations checksum implementation by timestamp invalidation.

Namespace

Drupal\memcache\Cache

Code

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

    // If there weren't any tags, the checksum should always be 0 or FALSE.
    return $checksum == 0;
  }
  return $checksum == $this
    ->calculateChecksum($tags);
}