function Store::save
Save data for the given key.
2 calls to Store::save()
- Store::invalidate in vendor/
symfony/ http-kernel/ HttpCache/ Store.php - Invalidates all cache entries that match the request.
- Store::write in vendor/
symfony/ http-kernel/ HttpCache/ Store.php - Writes a cache entry to the store for the given Request and Response.
File
-
vendor/
symfony/ http-kernel/ HttpCache/ Store.php, line 363
Class
- Store
- Store implements all the logic for storing cache metadata (Request and Response headers).
Namespace
Symfony\Component\HttpKernel\HttpCacheCode
private function save(string $key, string $data, bool $overwrite = true) : bool {
$path = $this->getPath($key);
if (!$overwrite && file_exists($path)) {
return true;
}
if (isset($this->locks[$key])) {
$fp = $this->locks[$key];
@ftruncate($fp, 0);
@fseek($fp, 0);
$len = @fwrite($fp, $data);
if (\strlen($data) !== $len) {
@ftruncate($fp, 0);
return false;
}
}
else {
if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
return false;
}
$tmpFile = tempnam(\dirname($path), basename($path));
if (false === ($fp = @fopen($tmpFile, 'w'))) {
@unlink($tmpFile);
return false;
}
@fwrite($fp, $data);
@fclose($fp);
if ($data != file_get_contents($tmpFile)) {
@unlink($tmpFile);
return false;
}
if (false === @rename($tmpFile, $path)) {
@unlink($tmpFile);
return false;
}
}
@chmod($path, 0666 & ~umask());
return true;
}