vrod

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

kip

ex_cldr Core Team

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 dets module 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 same dets file, they will all share the file. The file is properly closed when all users has either terminated or closed the file. dets files are not properly closed if the Erlang runtime system is terminated abnormally.

Also Liked

gregvaughn

gregvaughn

Try exiting iex with ^g followed by q. I’ve been told that is a kinder, gentler way to exit.

Last Post!

gregvaughn

gregvaughn

Try exiting iex with ^g followed by q. I’ve been told that is a kinder, gentler way to exit.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement