<?php
namespace wcf\system\cache\source;
use wcf\system\exception\SystemException;
-use wcf\system\io\File;
+use wcf\system\io\AtomicWriter;
use wcf\system\Callback;
use wcf\system\Regex;
use wcf\system\WCF;
* @see \wcf\system\cache\source\ICacheSource::set()
*/
public function set($cacheName, $value, $maxLifetime) {
- $file = new File($this->getFilename($cacheName));
- $file->write("<?php exit; /* cache: ".$cacheName." (generated at ".gmdate('r').") DO NOT EDIT THIS FILE */ ?>\n");
- $file->write(serialize($value));
- $file->close();
+ $writer = new AtomicWriter($this->getFilename($cacheName));
+ $writer->write("<?php exit; /* cache: ".$cacheName." (generated at ".gmdate('r').") DO NOT EDIT THIS FILE */ ?>\n");
+ $writer->write(serialize($value));
+ $writer->flush();
+ $writer->close();
// unset current DirectoryUtil object to make sure new cache file
// can be deleted in the same request