Example #1
0
 /**
  * Constructs the cache
  *
  * @param string $identifier A identifier which describes this cache
  * @param BackendInterface $backend Backend to be used for this cache
  * @throws \InvalidArgumentException if the identifier doesn't match PATTERN_ENTRYIDENTIFIER
  */
 public function __construct($identifier, BackendInterface $backend)
 {
     if (preg_match(self::PATTERN_ENTRYIDENTIFIER, $identifier) !== 1) {
         throw new \InvalidArgumentException('"' . $identifier . '" is not a valid cache identifier.', 1203584729);
     }
     $this->identifier = $identifier;
     $this->backend = $backend;
     $this->backend->setCache($this);
 }
 /**
  * Set cache frontend instance and calculate data and tags table name
  *
  * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The frontend for this backend
  * @return void
  * @api
  */
 public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $this->cacheTable = 'cf_' . $this->cacheIdentifier;
     $this->tagsTable = 'cf_' . $this->cacheIdentifier . '_tags';
     $this->initializeCommonReferences();
 }
Example #3
0
 /**
  * Set cache frontend instance and calculate data and tags table name
  *
  * @param FrontendInterface $cache The frontend for this backend
  * @return void
  * @api
  */
 public function setCache(FrontendInterface $cache)
 {
     parent::setCache($cache);
     $this->cacheTable = 'cf_' . $this->cacheIdentifier;
     $this->tagsTable = 'cf_' . $this->cacheIdentifier . '_tags';
     $this->maximumLifetime = self::FAKED_UNLIMITED_EXPIRE - $GLOBALS['EXEC_TIME'];
 }
Example #4
0
 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache
  * @return void
  */
 public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
     $pathHash = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(PATH_site . $processUser['name'] . $this->context, 12);
     $this->identifierPrefix = 'TYPO3_' . $pathHash;
 }
 /**
  * Sets a reference to the cache frontend which uses this backend and
  * initializes the default cache directory.
  *
  * TYPO3 v4 note: This method is different between TYPO3 v4 and FLOW3
  * because the Environment class to get the path to a temporary directory
  * does not exist in v4.
  *
  * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The cache frontend
  * @throws \TYPO3\CMS\Core\Cache\Exception
  * @return void
  */
 public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     if (empty($this->temporaryCacheDirectory)) {
         // If no cache directory was given with cacheDirectory
         // configuration option, set it to a path below typo3temp/
         $temporaryCacheDirectory = PATH_site . 'typo3temp/';
     } else {
         $temporaryCacheDirectory = $this->temporaryCacheDirectory;
     }
     $codeOrData = $cache instanceof \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend ? 'Code' : 'Data';
     $finalCacheDirectory = $temporaryCacheDirectory . 'Cache/' . $codeOrData . '/' . $this->cacheIdentifier . '/';
     if (!is_dir($finalCacheDirectory)) {
         $this->createFinalCacheDirectory($finalCacheDirectory);
     }
     unset($this->temporaryCacheDirectory);
     $this->cacheDirectory = $finalCacheDirectory;
     $this->cacheEntryFileExtension = $cache instanceof \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend ? '.php' : '';
     if (strlen($this->cacheDirectory) + 23 > \TYPO3\CMS\Core\Utility\GeneralUtility::getMaximumPathLength()) {
         throw new \TYPO3\CMS\Core\Cache\Exception('The length of the temporary cache file path "' . $this->cacheDirectory . '" exceeds the ' . 'maximum path length of ' . (\TYPO3\CMS\Core\Utility\GeneralUtility::getMaximumPathLength() - 23) . '. Please consider ' . 'setting the temporaryDirectoryBase option to a shorter path.', 1248710426);
     }
 }
 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The frontend for this backend
  * @return void
  */
 public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $identifierHash = substr(md5(PATH_site . $this->context . $this->cacheIdentifier), 0, 12);
     $this->identifierPrefix = 'TYPO3_' . $identifierHash . '_';
 }
Example #7
0
 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache
  * @return void
  */
 public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $processUser = $this->getCurrentUserData();
     $pathHash = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($this->getPathSite() . $processUser['name'] . $this->context . $cache->getIdentifier(), 12);
     $this->setIdentifierPrefix('TYPO3_' . $pathHash);
 }
Example #8
0
 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The frontend for this backend
  * @return void
  */
 public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $this->identifierPrefix = 'TYPO3_' . md5(PATH_site) . '_';
 }