diff --git a/core/core.services.yml b/core/core.services.yml index 4e1b13b..b3b0228 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -39,7 +39,7 @@ services: tags: - { name: service_collector, call: addInvalidator } cache_tags.checksum: - class: Drupal\Core\Cache\DatabaseCacheTagsStorage + class: Drupal\Core\Cache\DatabaseCacheTagsChecksum arguments: ['@database'] tags: - { name: cache_tags_invalidator} diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php index 0a519f4..784294e 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php +++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php @@ -11,7 +11,7 @@ use Drupal\Core\Database\SchemaObjectExistsException; /** - * Storage for cache tag invalidations. + * Cache tags invalidations checksum implementation that uses the database. */ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTagsInvalidatorInterface { @@ -81,6 +81,25 @@ public function invalidateTags(array $tags) { * {@inheritdoc} */ public function getCurrentChecksum(array $tags) { + // Remove tags that were already invalidated during this request from the + // static caches so that another deletion or invalidation can occur. + foreach ($tags as $tag) { + unset($this->invalidatedTags[$tag]); + } + return $this->calculateChecksum($tags); + } + + /** + * {@inheritdoc} + */ + public function isValid($checksum, array $tags) { + return $checksum == $this->calculateChecksum($tags); + } + + /** + * {@inheritdoc} + */ + public function calculateChecksum(array $tags) { $checksum = 0; $query_tags = array_diff($tags, array_keys($this->tagCache)); @@ -111,17 +130,6 @@ public function getCurrentChecksum(array $tags) { /** * {@inheritdoc} */ - public function onCacheTagsWrite(array $tags) { - // Remove tags that were already invalidated during this request from the - // static caches so that another deletion or invalidation can occur. - foreach ($tags as $tag) { - unset($this->invalidatedTags[$tag]); - } - } - - /** - * {@inheritdoc} - */ public function reset() { $this->tagCache = array(); $this->invalidatedTags = array();