How to properly close a dets file?

Sometimes when I stop an app where I have been writing to a dets table, when I later open it it shows:
dets: file "records" not properly closed, repairing ...
Although the file seems to be quite ok once opened.

On the app I’m just starting the dets table, doing a bunch of insert_new into it and not worrying about anything else. Is there a proper way of closing a dets once I’ve written to it?

1 Like

I’d try :dets.close/1:

Closes a table. Only processes that have opened a table are allowed to close it.

All open tables must be closed before the system is stopped. If an attempt is made to open a table that is not properly closed, Dets automatically tries to repair it.

1 Like

Forgot to go search on the erlang docs… Thanks!

1 Like