Neos\Cache\Backend\MemcachedBackend::get PHP Method

get() public method

Loads data from the cache.
public get ( string $entryIdentifier ) : mixed
$entryIdentifier string An identifier which describes the cache entry to load
return mixed The cache entry's content as a string or FALSE if the cache entry could not be loaded
    public function get($entryIdentifier)
    {
        $value = $this->memcache->get($this->identifierPrefix . $entryIdentifier);
        if (substr($value, 0, 13) === 'Flow*chunked:') {
            list(, $chunkCount) = explode(':', $value);
            $value = '';
            for ($chunkNumber = 1; $chunkNumber < $chunkCount; $chunkNumber++) {
                $value .= $this->memcache->get($this->identifierPrefix . $entryIdentifier . '_chunk_' . $chunkNumber);
            }
        }
        return $value;
    }

Usage Example

 /**
  * @test
  */
 public function flushRemovesOnlyOwnEntries()
 {
     $backendOptions = ['servers' => ['localhost:11211']];
     $thisCache = $this->getMockBuilder(AbstractFrontend::class)->disableOriginalConstructor()->getMock();
     $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
     $thisBackend = new MemcachedBackend($this->getEnvironmentConfiguration(), $backendOptions);
     $thisBackend->setCache($thisCache);
     $thatCache = $this->getMockBuilder(AbstractFrontend::class)->disableOriginalConstructor()->getMock();
     $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
     $thatBackend = new MemcachedBackend($this->getEnvironmentConfiguration(), $backendOptions);
     $thatBackend->setCache($thatCache);
     $thisBackend->set('thisEntry', 'Hello');
     $thatBackend->set('thatEntry', 'World!');
     $thatBackend->flush();
     $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
     $this->assertFalse($thatBackend->has('thatEntry'));
 }