diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php index 1523ea2a965a796ad75cca45b8ef513b3a4cfb34..559cff78403cc23cdf07cd27d195644a82869b11 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php @@ -160,7 +160,9 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { if ($cids) { foreach ($this->consistentBackend->getMultiple($cids, $allow_invalid) as $item) { $cache[$item->cid] = $item; - $this->fastBackend->set($item->cid, $item->data, $item->expire, $item->tags); + // Don't write the cache tags to the fast backend as any cache tag + // invalidation results in an invalidation of the whole fast backend. + $this->fastBackend->set($item->cid, $item->data, $item->expire); } } @@ -173,7 +175,9 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { $this->consistentBackend->set($cid, $data, $expire, $tags); $this->markAsOutdated(); - $this->fastBackend->set($cid, $data, $expire, $tags); + // Don't write the cache tags to the fast backend as any cache tag + // invalidation results in an invalidation of the whole fast backend. + $this->fastBackend->set($cid, $data, $expire); } /** @@ -182,6 +186,11 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array public function setMultiple(array $items) { $this->consistentBackend->setMultiple($items); $this->markAsOutdated(); + // Don't write the cache tags to the fast backend as any cache tag + // invalidation results in an invalidation of the whole fast backend. + foreach ($items as &$item) { + unset($item['tags']); + } $this->fastBackend->setMultiple($items); } diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php index 97d7ccd6113ab5f17b944a266ffc6049f407eff4..d6f31bfcc28b629283062bc9b3928a3dfffc6ce0 100644 --- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -411,7 +411,6 @@ public function testSetMultiple() { $this->assertEqual($cached['cid_4']->expire, $future_expiration, 'Cache expiration has been correctly set.'); $this->assertEqual($cached['cid_5']->data, $items['cid_5']['data'], 'New cache item set correctly.'); - $this->assertEqual($cached['cid_5']->tags, array('test:a', 'test:b')); // Calling ::setMultiple() with invalid cache tags. try { diff --git a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php index 798f37d7d7692fbd5757687503136e704034230a..c2640f2c56e38866a5a947a9bc7dcfbe801e0491 100644 --- a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php @@ -103,7 +103,7 @@ public function testFallThroughToConsistentCache() { // We should get a call to set the cache item on the fast backend. $fast_cache->expects($this->once()) ->method('set') - ->with($cache_item->cid, $cache_item->data, $cache_item->expire, $cache_item->tags); + ->with($cache_item->cid, $cache_item->data, $cache_item->expire); $chained_fast_backend = new ChainedFastBackend( $consistent_cache,