vrod
:dets -- close file after each write?
When using :dets should I close the file after each write operation? I see many warnings like this:
dets: file "/my/file" not properly closed, repairing ...
they seem to go away if I close the file after each write operation but this feels like it might be slow.
Thanks for any advice!
Marked As Solved
kip
The BEAM will close the file when the process that opened it exits - unless the exit is abnormal. ^c is an a abnormal exit so if you’re test in exs and thats how you exit then I think the error is to be expected.
Front the docs:
A file must be opened and closed. If a file has not been properly closed, the
detsmodule will automatically repair the file. This might take some time if the file is very large. By default, files are closed if the process which opened the file terminates. If several Erlang processes open the samedetsfile, they will all share the file. The file is properly closed when all users has either terminated or closed the file.detsfiles are not properly closed if the Erlang runtime system is terminated abnormally.
Also Liked
gregvaughn
Try exiting iex with ^g followed by q. I’ve been told that is a kinder, gentler way to exit.







