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

has() public method

Checks if a cache entry with the specified identifier exists.
public has ( string $entryIdentifier ) : boolean
$entryIdentifier string An identifier specifying the cache entry
return boolean TRUE if such an entry exists, FALSE if not
    public function has($entryIdentifier)
    {
        $success = false;
        apc_fetch($this->identifierPrefix . 'entry_' . $entryIdentifier, $success);
        return $success;
    }

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'));
 }