2 ms·
I think is more complex than that, when you modify some data structure in memory you also want write to disk immediately as to not lose any data in case of a cr
by Scarbutt 8y ago
I think is more complex than that, when you modify some data structure in memory you also want write to disk immediately as to not lose any data in case of a crash, so this means to write the new file under a separate name and then renaming the new file to replace the old file only after it has been successfully written as to provide safety against storage corruption.
I wouldn't recommend this to a beginner, the sqlite driver(of your language) would handle all this for you in a safe way.
- int_19h 8y ago> this means to write the new file under a separate name and then renaming the new file to replace the old file only after it has been successfully written as to provide safety against storage corruption I agree, that's about the only bit of complexity in all this. But it's completely generic, so it can be made into a small library, and then reused without dealing with the complexity every time. For example: https://www.npmjs.com/package/write-file-atomic https://www.npmjs.com/package/write-file-atomic