Earlier quoted context omitted.
> flush to disk periodically How do you protect yourself against incomplete writes? What about when there's a critical update that you don't want lost? I've done similar stuff in the past, but I handled things slightly differently. For tiny data structures I just spat out a short XML file. For larger data structures I synchronized all changes with a SQLite database.
> How do you protect yourself against incomplete writes? I don't update files on disk in-place. I write to a new file, and once it's done I do an atomic move and replace the old file with the new one. > What about when there's a critical update that you don't want lost? I immediately write it to the disk? (: I don't think it's possible to completely avoid this problem. In a traditional database if you suddenly lose p…
The old version of the application that was written before my version always wrote the entire file like you do. But when the file got very large it was too slow, which was why we used SQLite in newer versions.