/**
  * Constructs the cache
  *
  * @param string $identifier A identifier which describes this cache
  * @param \F3\FLOW3\Cache\Backend\BackendInterface $backend Backend to be used for this cache
  * @author Robert Lemke <*****@*****.**>
  * @throws \InvalidArgumentException if the identifier doesn't match PATTERN_ENTRYIDENTIFIER
  */
 public function __construct($identifier, \F3\FLOW3\Cache\Backend\BackendInterface $backend)
 {
     if (!preg_match(self::PATTERN_ENTRYIDENTIFIER, $identifier)) {
         throw new \InvalidArgumentException('"' . $identifier . '" is not a valid cache identifier.', 1203584729);
     }
     $this->identifier = $identifier;
     $this->backend = $backend;
     $this->backend->setCache($this);
 }
예제 #2
0
 /**
  * Sets a reference to the cache frontend which uses this backend and
  * initializes the default cache directory
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function setCache(\F3\FLOW3\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $cacheDirectory = $this->environment->getPathToTemporaryDirectory() . 'Cache/' . $this->cacheIdentifier . '/';
     if (!is_writable($cacheDirectory)) {
         try {
             \F3\FLOW3\Utility\Files::createDirectoryRecursively($cacheDirectory);
         } catch (\F3\FLOW3\Utility\Exception $exception) {
             throw new \F3\FLOW3\Cache\Exception('The cache directory "' . $cacheDirectory . '" could not be created.', 1264426237);
         }
     }
     if (!is_dir($cacheDirectory)) {
         throw new \F3\FLOW3\Cache\Exception('The cache directory "' . $cacheDirectory . '" does not exist.', 1203965199);
     }
     if (!is_writable($cacheDirectory)) {
         throw new \F3\FLOW3\Cache\Exception('The cache directory "' . $cacheDirectory . '" is not writable.', 1203965200);
     }
     $this->cacheDirectory = $cacheDirectory;
 }
예제 #3
0
 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \F3\FLOW3\Cache\Frontend\FrontendInterface $cache
  * @return void
  * @author Robert Lemke <*****@*****.**>
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function setCache(\F3\FLOW3\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
     $this->scope = substr(md5(FLOW3_PATH_WEB . $this->environment->getSAPIName() . $processUser['name'] . $this->context), 0, 12);
 }
 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \F3\FLOW3\Cache\Frontend\FrontendInterface $cache
  * @return void
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function setCache(\F3\FLOW3\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $this->identifierPrefix = 'FLOW3_' . md5($cache->getIdentifier() . $this->environment->getScriptPathAndFilename() . $this->environment->getSAPIName()) . '_';
 }