异步写文件,与swoole_async_writefile
不同,swoole_async_write
是分段写的。不需要一次性将要写的内容放到内存里,所以只占用少量内存。swoole_async_write
通过传入的offset参数来确定写入的位置。
bool swoole_async_write(string $filename, string $content, int $offset = -1, mixed $callback = NULL);
$content
的长度和$offset
必须为512的整数倍。如果传入错误的字符串长度或者$offset
写入会失败,并且错误码为EINVAL