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; } }
/** * 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); } }