Beispiel #1
0
 /**
  * Retrieves data from the cache identified by the specified key
  *
  * @param string $key   The key.
  *
  * @return mixed
  *
  * @throws \YapepBase\Exception\StorageException   On error.
  */
 public function get($key)
 {
     $startTime = microtime(true);
     $fileName = $this->makeFullPath($key);
     $data = false;
     if ($this->fileHandler->checkIsPathExists($fileName)) {
         if (!$this->fileHandler->checkIsReadable($fileName) || ($contents = $this->fileHandler->getAsString($fileName)) === false) {
             throw new StorageException('Unable to read file: ' . $fileName);
         }
         $data = $this->readData($contents);
         if (false === $data) {
             try {
                 $this->fileHandler->remove($fileName);
             } catch (FileException $e) {
                 throw new StorageException('Unable to remove empty file: ' . $fileName, 0, $e);
             }
         }
     }
     $debugger = Application::getInstance()->getDiContainer()->getDebugger();
     if (!$this->debuggerDisabled && $debugger !== false) {
         $debugger->addItem(new StorageItem('file', 'file.' . $this->currentConfigurationName, StorageItem::METHOD_GET . ' ' . $key, $data, microtime(true) - $startTime));
     }
     return $data;
 }