Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function get($key)
 {
     if ($this->fileSystem->exists($this->cacheFile($key))) {
         // Cache exists
         $file = $this->fileSystem->file($this->cacheFile($key), 'r');
         if (time() < (int) trim($file->fgets())) {
             // Cache has not expired ... fetch it
             $cache = '';
             while (!$file->eof()) {
                 $cache .= $file->fgets();
             }
             unset($file);
             return unserialize($cache);
         } else {
             // Cache has expired ... delete it
             unset($file);
             $this->fileSystem->delete($this->cacheFile($key));
             return false;
         }
     } else {
         // Cache doesn't exist
         return false;
     }
 }