Issue #2392235 by Berdir: ChainedFastBackend shouldn't write cache tags to the fast cache back-end

8.0.x
Nathaniel Catchpole 2014-12-16 18:03:51 +00:00
parent 14669c9367
commit 723ac9580b
3 changed files with 12 additions and 4 deletions

View File

@ -160,7 +160,9 @@ class ChainedFastBackend implements CacheBackendInterface {
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 @@ class ChainedFastBackend implements CacheBackendInterface {
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 @@ class ChainedFastBackend implements CacheBackendInterface {
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);
}

View File

@ -411,7 +411,6 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$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 {

View File

@ -103,7 +103,7 @@ class ChainedFastBackendTest extends UnitTestCase {
// 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,