Answer the question
In order to leave comments, you need to log in
How easy and safe is it to write to a file?
Good afternoon. We have https://github.com/orcaman/concurrent-map everywhere, and now the architects have set me the task of adding saving the map on disk so that in the event of a crash, we immediately start with a warm cache without pain. I’ll make a reservation right away: take redis, tarantool, etc. why not, I don't know.
Requirements: write to a file (thread safety is not important) and if a panic suddenly pops up somewhere, a termination signal comes or the process is simply killed, then it should correctly write to a file, a kind of transaction system for the file system.
I don't want to bike. Maybe somewhere this is already written.
UPD.
A log of all operations will be written to the file. roughly speaking, I will make a storage system like in a tarantula (binlog + snapshot)
Answer the question
In order to leave comments, you need to log in
When saving, write first to a separate temporary file, and then move it to the desired location.
Note that your map will be read-only when saved to a file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question