Achieve atomic cache writes using file_put_contents to temp file, followed by rename.