public function CacheTest::testDeleteAllAndNamespaceVersioningBetweenCaches in Plug 7
File
- lib/
doctrine/ cache/ tests/ Doctrine/ Tests/ Common/ Cache/ CacheTest.php, line 106
Class
Namespace
Doctrine\Tests\Common\CacheCode
public function testDeleteAllAndNamespaceVersioningBetweenCaches() {
if (!$this
->isSharedStorage()) {
$this
->markTestSkipped('The ' . __CLASS__ . ' does not use shared storage');
}
$cache1 = $this
->_getCacheDriver();
$cache2 = $this
->_getCacheDriver();
$this
->assertTrue($cache1
->save('key1', 1));
$this
->assertTrue($cache2
->save('key2', 2));
/* Both providers are initialized with the same namespace version, so
* they can see entries set by each other.
*/
$this
->assertTrue($cache1
->contains('key1'));
$this
->assertTrue($cache1
->contains('key2'));
$this
->assertTrue($cache2
->contains('key1'));
$this
->assertTrue($cache2
->contains('key2'));
/* Deleting all entries through one provider will only increment the
* namespace version on that object (and in the cache itself, which new
* instances will use to initialize). The second provider will retain
* its original version and still see stale data.
*/
$this
->assertTrue($cache1
->deleteAll());
$this
->assertFalse($cache1
->contains('key1'));
$this
->assertFalse($cache1
->contains('key2'));
$this
->assertTrue($cache2
->contains('key1'));
$this
->assertTrue($cache2
->contains('key2'));
/* A new cache provider should not see the deleted entries, since its
* namespace version will be initialized.
*/
$cache3 = $this
->_getCacheDriver();
$this
->assertFalse($cache3
->contains('key1'));
$this
->assertFalse($cache3
->contains('key2'));
}