erlang 文件流: Elixir

vom3gejh  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(178)

我经常在Elixir论坛上看到:

"path/to/file"
|> File.stream!(read_ahead: 100_000)
  • 预读的内容:100_000* 表示什么?
6rvt4ljy

6rvt4ljy1#

It is one of stream_mode's. It's meaning is described in erlang documentation:
{read_ahead, Size} Activates read data buffering. If read/2 calls are for significantly less than Size bytes, read operations to the operating system are still performed for blocks of Size bytes. The extra data is buffered and returned in subsequent read/2 calls, giving a performance gain as the number of operating system calls is reduced.

相关问题