Save data for the given key.
string $key The store key:
string $data The data to store:
Boolean
private function save($key, $data) {
$path = $this
->getPath($key);
if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) {
return false;
}
$tmpFile = tempnam(dirname($path), basename($path));
if (false === ($fp = @fopen($tmpFile, 'wb'))) {
return false;
}
@fwrite($fp, $data);
@fclose($fp);
if ($data != file_get_contents($tmpFile)) {
return false;
}
if (false === @rename($tmpFile, $path)) {
return false;
}
@chmod($path, 0666 & ~umask());
}