/**
  * Factory method which creates the specified cache along with the specified kind of backend.
  * After creating the cache, it will be registered at the cache manager.
  *
  * @param string $cacheIdentifier The name / identifier of the cache to create
  * @param string $cacheName Name of the cache frontend
  * @param string $backendName Name of the cache backend
  * @param array $backendOptions (optional) Array of backend options
  * @return t3lib_cache_frontend_Frontend The created cache frontend
  * @author Robert Lemke <*****@*****.**>
  */
 public function create($cacheIdentifier, $cacheName, $backendName, array $backendOptions = array())
 {
     // loading the cache backend file and class
     list($backendFile, $backendClassReference) = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackends'][$backendName]);
     $backendRequireFile = t3lib_div::getFileAbsFileName($backendFile);
     if ($backendRequireFile) {
         t3lib_div::requireOnce($backendRequireFile);
     }
     $backend = t3lib_div::makeInstance($backendClassReference, $backendOptions);
     if (!$backend instanceof t3lib_cache_backend_Backend) {
         throw new t3lib_cache_exception_InvalidCache('"' . $backendName . '" is not a valid cache backend.', 1216304301);
     }
     // loading the cache frontend file and class
     list($cacheFile, $cacheClassReference) = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheFrontends'][$cacheName]);
     $cacheRequireFile = t3lib_div::getFileAbsFileName($cacheFile);
     if ($cacheRequireFile) {
         t3lib_div::requireOnce($cacheRequireFile);
     }
     $cache = t3lib_div::makeInstance($cacheClassReference, $cacheIdentifier, $backend);
     if (!$cache instanceof t3lib_cache_frontend_Frontend) {
         throw new t3lib_cache_exception_InvalidCache('"' . $cacheName . '" is not a valid cache.', 1216304300);
     }
     $this->cacheManager->registerCache($cache);
     return $cache;
 }
 /**
  * Factory method which creates the specified cache along with the specified kind of backend.
  * After creating the cache, it will be registered at the cache manager.
  *
  * @param string $cacheIdentifier The name / identifier of the cache to create
  * @param string $cacheName Name of the cache frontend
  * @param string $backendName Name of the cache backend
  * @param array $backendOptions (optional) Array of backend options
  * @return t3lib_cache_frontend_Frontend The created cache frontend
  * @author Robert Lemke <*****@*****.**>
  */
 public function create($cacheIdentifier, $cacheName, $backendName, array $backendOptions = array())
 {
     $backendReference = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackends'][$backendName];
     if (strpos($backendReference, ':') === FALSE) {
         $backendClassReference = $backendReference;
     } else {
         t3lib_div::deprecationLog("Configuring cacheBackend with filename is deprecated since TYPO3 4.5. Use the autoloader instead.");
         // loading the cache backend file and class
         list($backendFile, $backendClassReference) = explode(':', $backendReference);
         $backendRequireFile = t3lib_div::getFileAbsFileName($backendFile);
         if ($backendRequireFile) {
             t3lib_div::requireOnce($backendRequireFile);
         }
     }
     $backend = t3lib_div::makeInstance($backendClassReference, $backendOptions);
     if (!$backend instanceof t3lib_cache_backend_Backend) {
         throw new t3lib_cache_exception_InvalidCache('"' . $backendName . '" is not a valid cache backend.', 1216304301);
     }
     $cacheReference = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheFrontends'][$cacheName];
     if (strpos($cacheReference, ':') === FALSE) {
         $cacheClassReference = $cacheReference;
     } else {
         t3lib_div::deprecationLog("Configuring cacheFrontends with filename is deprecated since TYPO3 4.5. Use the autoloader instead.");
         // loading the cache frontend file and class
         list($cacheFile, $cacheClassReference) = explode(':', $cacheReference);
         $cacheRequireFile = t3lib_div::getFileAbsFileName($cacheFile);
         if ($cacheRequireFile) {
             t3lib_div::requireOnce($cacheRequireFile);
         }
     }
     $cache = t3lib_div::makeInstance($cacheClassReference, $cacheIdentifier, $backend);
     if (!$cache instanceof t3lib_cache_frontend_Frontend) {
         throw new t3lib_cache_exception_InvalidCache('"' . $cacheName . '" is not a valid cache.', 1216304300);
     }
     $this->cacheManager->registerCache($cache);
     return $cache;
 }
 /**
  * @test
  * @author Robert Lemke <*****@*****.**>
  * @author Ingo Renner <*****@*****.**>
  */
 public function flushCachesCallsTheFlushMethodOfAllRegisteredCaches()
 {
     $manager = new t3lib_cache_Manager();
     $backend = $this->getMock('t3lib_cache_backend_AbstractBackend', array(), array(), '', FALSE);
     $cache1 = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', FALSE);
     $cache1->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('cache1'));
     $cache1->expects($this->once())->method('flush');
     $manager->registerCache($cache1);
     $cache2 = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', FALSE);
     $cache2->expects($this->once())->method('flush');
     $manager->registerCache($cache2);
     $manager->flushCaches();
 }