/** * Initializes the cache framework * * @return void */ protected function initializeCache() { $this->cacheManager = $GLOBALS['typo3CacheManager']; try { $this->cache = $this->cacheManager->getCache(self::CACHE_IDENTIFIER); } catch (t3lib_cache_exception_NoSuchCache $exception) { $this->cache = $GLOBALS['typo3CacheFactory']->create(self::CACHE_IDENTIFIER, 't3lib_cache_frontend_VariableFrontend', 't3lib_cache_backend_FileBackend', array('cacheDirectory' => 'typo3temp/tx_powered/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()) { // 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; }
/** * Initializes the Reflection Service * * @return void */ protected function initializeReflection() { self::$reflectionService = t3lib_div::makeInstance('Tx_Extbase_Reflection_Service'); self::$reflectionService->setCache($this->cacheManager->getCache('cache_extbase_reflection')); if (!self::$reflectionService->isInitialized()) { self::$reflectionService->initialize(); } }
/** * Initializes the Reflection Service * * @return void * @see initialize() */ protected function initializeReflection() { $this->reflectionService = $this->objectManager->get('Tx_Extbase_Reflection_Service'); $this->reflectionService->setDataCache($this->cacheManager->getCache('cache_extbase_reflection')); if (!$this->reflectionService->isInitialized()) { $this->reflectionService->initialize(); } }
/** * 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; }
/** * Get a cache frontend by its identifier. * * @param string $cacheIdentifier The cache identifier. * @return t3lib_cache_frontend_FrontendInterface The cache frontend. * @author Romain Ruetschi <*****@*****.**> */ public function getCache($cacheIdentifier) { return $this->cacheManager->getCache($cacheIdentifier); }
/** * @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(); }