Neos\Cache\Backend\ApcBackend::flush PHP Method

flush() public method

Removes all cache entries of this cache.
public flush ( ) : void
return void
    public function flush()
    {
        if (!$this->cache instanceof FrontendInterface) {
            throw new Exception('Yet no cache frontend has been set via setCache().', 1232986971);
        }
        $this->flushByTag('%APCBE%' . $this->cacheIdentifier);
    }

Usage Example

 /**
  * @test
  */
 public function flushRemovesOnlyOwnEntries()
 {
     $thisCache = $this->createMock(FrontendInterface::class);
     $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
     $thisBackend = new ApcBackend($this->getEnvironmentConfiguration(), []);
     $thisBackend->setCache($thisCache);
     $thatCache = $this->createMock(FrontendInterface::class);
     $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
     $thatBackend = new ApcBackend($this->getEnvironmentConfiguration(), []);
     $thatBackend->setCache($thatCache);
     $thisBackend->set('thisEntry', 'Hello');
     $thatBackend->set('thatEntry', 'World!');
     $thatBackend->flush();
     $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
     $this->assertFalse($thatBackend->has('thatEntry'));
 }