Loading core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php +5 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,6 @@ public function rootTransactionEndCallback($success) { * Implements \Drupal\Core\Cache\CacheTagsInvalidatorInterface::invalidateTags() */ public function invalidateTags(array $tags) { // Only invalidate tags once per request unless they are written again. foreach ($tags as $key => $tag) { if (isset($this->invalidatedTags[$tag])) { unset($tags[$key]); Loading Loading @@ -139,6 +138,11 @@ public function isValid($checksum, array $tags) { */ 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) { Loading core/modules/system/tests/modules/performance_test/src/Cache/CacheTagsChecksumDecorator.php +11 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,12 @@ public function __construct(protected readonly CacheTagsChecksumInterface $check * {@inheritdoc} */ public function getCurrentChecksum(array $tags) { // If there are no cache tags, there is no checksum to get and the decorated // method will be a no-op, so don't log anything. if (empty($tags)) { return $this->checksumInvalidator->getCurrentChecksum($tags); } $start = microtime(TRUE); $return = $this->checksumInvalidator->getCurrentChecksum($tags); $stop = microtime(TRUE); Loading Loading @@ -46,6 +52,11 @@ public function isValid($checksum, array $tags) { * {@inheritdoc} */ public function invalidateTags(array $tags) { // If there are no cache tags, there is nothing to invalidate, and the // decorated method will be a no-op, so don't log anything. if (empty($tags)) { return $this->checksumInvalidator->invalidateTags($tags); } $start = microtime(TRUE); $return = $this->checksumInvalidator->invalidateTags($tags); $stop = microtime(TRUE); Loading core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php +3 −2 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public function testAnonymous() { $this->assertSame(137, $performance_data->getCacheGetCount()); $this->assertSame(47, $performance_data->getCacheSetCount()); $this->assertSame(0, $performance_data->getCacheDeleteCount()); $this->assertCountBetween(143, 146, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(40, 43, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(47, 50, $performance_data->getCacheTagIsValidCount()); $this->assertSame(0, $performance_data->getCacheTagInvalidationCount()); Loading @@ -73,7 +73,7 @@ public function testAnonymous() { $this->assertSame(95, $performance_data->getCacheGetCount()); $this->assertSame(16, $performance_data->getCacheSetCount()); $this->assertSame(0, $performance_data->getCacheDeleteCount()); $this->assertCountBetween(79, 80, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(24, 25, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(41, 42, $performance_data->getCacheTagIsValidCount()); $this->assertSame(0, $performance_data->getCacheTagInvalidationCount()); Loading @@ -87,6 +87,7 @@ public function testAnonymous() { $this->assertSame(81, $performance_data->getCacheGetCount()); $this->assertSame(16, $performance_data->getCacheSetCount()); $this->assertSame(0, $performance_data->getCacheDeleteCount()); $this->assertCountBetween(24, 25, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(36, 37, $performance_data->getCacheTagIsValidCount()); $this->assertSame(0, $performance_data->getCacheTagInvalidationCount()); } Loading Loading
core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php +5 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,6 @@ public function rootTransactionEndCallback($success) { * Implements \Drupal\Core\Cache\CacheTagsInvalidatorInterface::invalidateTags() */ public function invalidateTags(array $tags) { // Only invalidate tags once per request unless they are written again. foreach ($tags as $key => $tag) { if (isset($this->invalidatedTags[$tag])) { unset($tags[$key]); Loading Loading @@ -139,6 +138,11 @@ public function isValid($checksum, array $tags) { */ 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) { Loading
core/modules/system/tests/modules/performance_test/src/Cache/CacheTagsChecksumDecorator.php +11 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,12 @@ public function __construct(protected readonly CacheTagsChecksumInterface $check * {@inheritdoc} */ public function getCurrentChecksum(array $tags) { // If there are no cache tags, there is no checksum to get and the decorated // method will be a no-op, so don't log anything. if (empty($tags)) { return $this->checksumInvalidator->getCurrentChecksum($tags); } $start = microtime(TRUE); $return = $this->checksumInvalidator->getCurrentChecksum($tags); $stop = microtime(TRUE); Loading Loading @@ -46,6 +52,11 @@ public function isValid($checksum, array $tags) { * {@inheritdoc} */ public function invalidateTags(array $tags) { // If there are no cache tags, there is nothing to invalidate, and the // decorated method will be a no-op, so don't log anything. if (empty($tags)) { return $this->checksumInvalidator->invalidateTags($tags); } $start = microtime(TRUE); $return = $this->checksumInvalidator->invalidateTags($tags); $stop = microtime(TRUE); Loading
core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php +3 −2 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public function testAnonymous() { $this->assertSame(137, $performance_data->getCacheGetCount()); $this->assertSame(47, $performance_data->getCacheSetCount()); $this->assertSame(0, $performance_data->getCacheDeleteCount()); $this->assertCountBetween(143, 146, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(40, 43, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(47, 50, $performance_data->getCacheTagIsValidCount()); $this->assertSame(0, $performance_data->getCacheTagInvalidationCount()); Loading @@ -73,7 +73,7 @@ public function testAnonymous() { $this->assertSame(95, $performance_data->getCacheGetCount()); $this->assertSame(16, $performance_data->getCacheSetCount()); $this->assertSame(0, $performance_data->getCacheDeleteCount()); $this->assertCountBetween(79, 80, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(24, 25, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(41, 42, $performance_data->getCacheTagIsValidCount()); $this->assertSame(0, $performance_data->getCacheTagInvalidationCount()); Loading @@ -87,6 +87,7 @@ public function testAnonymous() { $this->assertSame(81, $performance_data->getCacheGetCount()); $this->assertSame(16, $performance_data->getCacheSetCount()); $this->assertSame(0, $performance_data->getCacheDeleteCount()); $this->assertCountBetween(24, 25, $performance_data->getCacheTagChecksumCount()); $this->assertCountBetween(36, 37, $performance_data->getCacheTagIsValidCount()); $this->assertSame(0, $performance_data->getCacheTagInvalidationCount()); } Loading