setCache() публичный Метод

This method also detects if this backend is frozen and sets the internal flag accordingly.
public setCache ( Neos\Cache\Frontend\FrontendInterface $cache ) : void
$cache Neos\Cache\Frontend\FrontendInterface The cache frontend
Результат void
 /**
  * Creates a cache for testing
  *
  * @param string $name
  * @return VariableFrontend
  */
 protected function createCache($name)
 {
     $backend = new FileBackend(new EnvironmentConfiguration('Session Testing', 'vfs://Foo/', PHP_MAXPATHLEN));
     $cache = new VariableFrontend($name, $backend);
     $cache->initializeObject();
     $backend->setCache($cache);
     $cache->flush();
     return $cache;
 }
 /**
  * @test
  */
 public function backendAllowsForIteratingOverEntries()
 {
     $mockEnvironmentConfiguration = $this->createEnvironmentConfigurationMock([__DIR__ . '~Testing', 'vfs://Foo/', 255]);
     $backend = new FileBackend($mockEnvironmentConfiguration, []);
     $cache = new VariableFrontend('UnitTestCache', $backend);
     $backend->setCache($cache);
     for ($i = 0; $i < 100; $i++) {
         $entryIdentifier = sprintf('entry-%s', $i);
         $data = 'some data ' . $i;
         $cache->set($entryIdentifier, $data);
     }
     $entries = [];
     foreach ($cache->getIterator() as $entryIdentifier => $data) {
         $entries[$entryIdentifier] = $data;
     }
     natsort($entries);
     $i = 0;
     foreach ($entries as $entryIdentifier => $data) {
         $this->assertEquals(sprintf('entry-%s', $i), $entryIdentifier);
         $this->assertEquals('some data ' . $i, $data);
         $i++;
     }
     $this->assertEquals(100, $i);
 }