Beware: file_put_contents() is racy by design and if you use it to write serialize()d data, you may end up having error such as
unserialize(): Extra data starting at offset 1000 of 1002 bytes
For details, see https://github.com/php/php-src/issues/20108