3 ms·
1. Write your updates to a copy of the file. 1a. fsync() the file to ensure the contents are durable. 2. Do an atomic rename of that copy to the original. 2a
by fanf2 6y ago
1. Write your updates to a copy of the file.
1a. fsync() the file to ensure the contents are durable.
2. Do an atomic rename of that copy to the original.
2a. fsync() the directory to ensure the rename is durable.
- fiddlerwoaroof 6y agoOr just use a database like SQLite or Postgres that has developers dedicated to solving this problem.