function CacheTagsChecksumTrait::calculateChecksum
Same name in other branches
- 9 core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php \Drupal\Core\Cache\CacheTagsChecksumTrait::calculateChecksum()
- 8.9.x core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php \Drupal\Core\Cache\CacheTagsChecksumTrait::calculateChecksum()
- 11.x core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php \Drupal\Core\Cache\CacheTagsChecksumTrait::calculateChecksum()
Calculates the current checksum for a given set of tags.
Parameters
string[] $tags: The array of tags to calculate the checksum for.
Return value
int The calculated checksum.
2 calls to CacheTagsChecksumTrait::calculateChecksum()
- CacheTagsChecksumTrait::getCurrentChecksum in core/
lib/ Drupal/ Core/ Cache/ CacheTagsChecksumTrait.php - Implements \Drupal\Core\Cache\CacheTagsChecksumInterface::getCurrentChecksum()
- CacheTagsChecksumTrait::isValid in core/
lib/ Drupal/ Core/ Cache/ CacheTagsChecksumTrait.php - Implements \Drupal\Core\Cache\CacheTagsChecksumInterface::isValid()
File
-
core/
lib/ Drupal/ Core/ Cache/ CacheTagsChecksumTrait.php, line 139
Class
- CacheTagsChecksumTrait
- A trait for cache tag checksum implementations.
Namespace
Drupal\Core\CacheCode
protected function calculateChecksum(array $tags) {
$checksum = 0;
// If there are no cache tags, then there is no cache tag to checksum,
// so return early..
if (empty($tags)) {
return $checksum;
}
$query_tags = array_diff($tags, array_keys($this->tagCache));
if ($query_tags) {
$tag_invalidations = $this->getTagInvalidationCounts($query_tags);
$this->tagCache += $tag_invalidations;
// Fill static cache with empty objects for tags not found in the storage.
$this->tagCache += array_fill_keys(array_diff($query_tags, array_keys($tag_invalidations)), 0);
}
foreach ($tags as $tag) {
$checksum += $this->tagCache[$tag];
}
return $checksum;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.