Skip to content

Commit

Permalink
fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
shabeer-ali-m committed Jul 9, 2021
1 parent 43f52da commit 7086507
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/SuperCache/SuperCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public function set($val)
$val = str_replace('stdClass::__set_state', '(object)', $val);
// Write to temp file first to ensure atomicity
$tmp = $this->path . "$key." . uniqid('', true) . SuperCache::EXT;
file_put_contents($tmp, '<?php $val = ' . $val . ';', LOCK_EX);
$file = fopen($tmp, 'x');
fwrite ($file, '<?php $val=' . $val . ';');
fclose ($file);
rename($tmp, $this->path . $key);
return $this;
}
Expand Down

0 comments on commit 7086507

Please sign in to comment.