Exemple #1
0
 protected function setValue($key, $value, $duration)
 {
     $this->gc();
     $cacheFile = $this->getCacheFile($key);
     if ($this->directoryLevel > 0) {
         @FileHelper::createDirectory(dirname($cacheFile), $this->dirMode, true);
     }
     if (@file_put_contents($cacheFile, $value, LOCK_EX) !== false) {
         if ($this->fileMode !== null) {
             @chmod($cacheFile, $this->fileMode);
         }
         if ($duration <= 0) {
             $duration = 31536000;
             // 1 year
         }
         return @touch($cacheFile, $duration + time());
     } else {
         $error = error_get_last();
         return false;
     }
 }
Exemple #2
0
 /**
  * init runtime environment
  */
 protected function initEnvironment()
 {
     if (!is_writable($this->runtimePath)) {
         throw new Exception("{$this->runtimePath} is not writable");
     }
     if (!is_dir($this->runtimePath)) {
         FileHelper::createDirectory($this->runtimePath);
     }
 }