A plain "file_put_contents" can cause havoc

This tries to make the saving of cached file atomic. It creates a new
tempfile, writes the content to it and than renames it to the
destination file.
I just realized that it should be `uniqid('', true)` as per documentation at http://php.net/manual/en/function.uniqid.php