News for hackers. Stuff that matters.
Re:What are the best non-database solutions you've seen? Wha... by Tichy on Thursday April 19, 2007 @03:50PM (#14750)
I hope this is not totally embarrassing, but with the file system I am always afraid of losing data. What if something happens to the server at the very moment you change the file? It seems to me the only solution is to keep two files and change them alternately, like the double buffering for graphics, and that would probably be slow.

How do you file-advocates solve that problem?

What would you use for firefox extensions? I suppose I can't connect to a database with Javascript.

Re:What are the best non-database solutions you've seen? Wha... by aston on Thursday April 19, 2007 @03:56PM (#14753)
As of FF2, you can use the built in SQLite database for your Firefox extensions. And yes, it's accessible from Javascript. The interface is a lot like JDBC.
Re:What are the best non-database solutions you've seen? Wha... by Tichy on Thursday April 19, 2007 @04:57PM (#14783)
Hey thanks, that is really good to know. I am just toying around with the idea of writing an extension, and every now and then I collect new information. So far it seems a bit scary to me, but there are so many cool things one could make as extensions.
Re:What are the best non-database solutions you've seen? Wha... by shiro on Thursday April 19, 2007 @07:25PM (#14843)
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.