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

setCache() public method

Initializes the identifier prefix when setting the cache.
public setCache ( Neos\Cache\Frontend\FrontendInterface $cache ) : void
$cache Neos\Cache\Frontend\FrontendInterface
return void
    public function setCache(FrontendInterface $cache)
    {
        parent::setCache($cache);
        $pathHash = substr(md5($this->environmentConfiguration->getApplicationIdentifier() . $this->environmentConfiguration->getApplicationContext() . $cache->getIdentifier()), 0, 12);
        $this->identifierPrefix = 'Flow_' . $pathHash . '_';
    }

Usage Example

 /**
  * Sets up the memcached backend used for testing
  *
  * @param array $backendOptions Options for the memcache backend
  * @return MemcachedBackend
  */
 protected function setUpBackend(array $backendOptions = [])
 {
     $cache = $this->createMock(FrontendInterface::class, [], [], '', false);
     if ($backendOptions == []) {
         $backendOptions = ['servers' => ['localhost:11211']];
     }
     $backend = new MemcachedBackend($this->getEnvironmentConfiguration(), $backendOptions);
     $backend->setCache($cache);
     return $backend;
 }