- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
DETS Erlang 文档中描述了一个选项 ram_file
open_file(name, args)
{ram_file, boolean()}
- Whether the table is to be kept in RAM. Keeping the table in RAM can sound like an anomaly, but can enhance the performance of applications that open a table, insert a set of objects, and then close the table. When the table is closed, its contents are written to the disk file. Defaults tofalse
.
这将在插入或更新后在磁盘上执行保存
如果我会用呢打开 - 然后查找 - 然后关闭?
最佳答案
我没有查看文档,但我假设这意味着 VM 将打开文件并可能mmap
它,所以它一直保存在内存,它会与磁盘上的文件同步,但我认为更改仍然可以在缓存中结束,因此不会立即写入磁盘。如果您想确保所有更改都已刷新到磁盘,请使用 dets:sync/1
调用表以强制刷新数据,这在文档中有明确说明:
This also applies to tables that have been opened with flag
ram_file
set totrue
. In this case, the contents of the RAM file are flushed to disk.
它不会在每次查找后打开或关闭文件,但它会保持打开状态,直到 dets:close/1
不会在给定的表上调用。另一方面,为每次查找打开和关闭表可能代价高昂,因此这会使整个 DETS 的使用变得毫无意义。
关于erlang - dets 会在使用 ram_file 选项查找时执行磁盘读取吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59304443/
DETS Erlang 文档中描述了一个选项 ram_file open_file(name, args) {ram_file, boolean()} - Whether the table is t
我是一名优秀的程序员,十分优秀!