function ChainedFastBackendTest::testSet
Tests that sets only get written to the consistent backend.
File
-
core/
tests/ Drupal/ Tests/ Core/ Cache/ ChainedFastBackendTest.php, line 113
Class
Namespace
Drupal\Tests\Core\CacheCode
public function testSet() : void {
$consistent_cache = $this->createMock(CacheBackendInterface::class);
$fast_cache = $this->createMock(CacheBackendInterface::class);
// The initial write to the fast backend should result in two writes to the
// consistent backend, once to invalidate the last write timestamp and once
// for the item itself. However subsequent writes during the same second
// should only write to the cache item without further invalidations.
$consistent_cache->expects($this->exactly(5))
->method('set');
$fast_cache->expects($this->never())
->method('set');
$fast_cache->expects($this->never())
->method('setMultiple');
$chained_fast_backend = new ChainedFastBackend($consistent_cache, $fast_cache, 'foo');
$chained_fast_backend->set('foo', TRUE);
$chained_fast_backend->set('bar', TRUE);
$chained_fast_backend->set('baz', TRUE);
$chained_fast_backend->set('zoo', TRUE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.