core/lib/Drupal/Core/Cache/CacheTagsChecksumInterface.php | 6 +++--- core/lib/Drupal/Core/Cache/DatabaseBackend.php | 4 ++-- core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/CacheTagsChecksumInterface.php b/core/lib/Drupal/Core/Cache/CacheTagsChecksumInterface.php index 7032eb7..f3ef62b 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagsChecksumInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheTagsChecksumInterface.php @@ -21,9 +21,9 @@ /** * The checksum returned a database transaction is in progress. * - * Every cache backend SHOULD detect this and not write cache items with this - * checksum. Not detecting this would not yield incorrect cache reads, but - * would be a useless write. + * Every cache backend SHOULD detect this and not write cache items that have + * this checksum. Not detecting this would not yield incorrect cache reads, + * but would be a useless write. * * While a database transaction is progress, cache tag invalidations are * delayed to occur just before the commit, to allow: diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index d5939da..793089e 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -236,7 +236,7 @@ protected function doSetMultiple(array $items) { 'checksum' => $this->checksumProvider->getCurrentChecksum($item['tags']), ]; - // @see \Drupal\Core\Cache\CacheTagsChecksumInterface::CHECKSUM_WHILE_IN_TRANSACTION + // Avoid useless writes. if ($fields['checksum'] === CacheTagsChecksumInterface::CHECKSUM_WHILE_IN_TRANSACTION) { continue; } @@ -252,7 +252,7 @@ protected function doSetMultiple(array $items) { $values[] = $fields; } - // @see \Drupal\Core\Cache\CacheTagsChecksumInterface::CHECKSUM_WHILE_IN_TRANSACTION + // If all $items were useless writes, we may end up with zero writes. if (empty($values)) { return; } diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php index 7b6097c..f52782e 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php +++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php @@ -77,7 +77,10 @@ public function invalidateTags(array $tags) { } /** - * Helper method for ::invalidateTags(). + * Marks cache items with any of the specified tags as invalid. + * + * @param string[] $tags + * The list of tags for which to invalidate cache items. */ protected function doInvalidateTags(array $tags) { try {