2 ms·
A few techniques I've used: If the file is small, I write to a tmp file then rename. If multiple files are involved, I write new data to fresh files, then upd
by shiro 20y ago
A few techniques I've used:
If the file is small, I write to a tmp file then rename.
If multiple files are involved, I write new data to fresh files, then update the "master" file atomically that has pointer to the data files.
If lots of data is constantly added, I just keep appending to a file, but design the format so that I can always find the record boundary even if the last append was chopped by server crash.