2 ms·
> It is best to cache metadata And the thing you cache it in is called a database. You may choose to eschew an SQL database, or a no-SQL database, and roll you
by jcranmer 7y ago
> It is best to cache metadata
And the thing you cache it in is called a database. You may choose to eschew an SQL database, or a no-SQL database, and roll your own implementation of a database, but you are building a database in some fashion.
> there are lot of benefits of saving emails as files that can be read from the file system
And now you're using the filesystem as key-value store, aka, database. Except since you're preserving metadata in a distinct database, now you have to maintain ACID qualities across two databases, one of which is pretty notorious for lying to you about durability. Or you can recognize that you're probably not very good at actually dealing with databases, and delegate the task to a proper database who has people on staff who actually worry about these sorts of scenarios.
> generally this isn't a problem unless you have unknown software accessing the same data as your program.
The most common such program is... backup software. Especially the kind that says backups are "copy all files in these directories," which I'm guessing is the kind of backup software that you advocate for.
But you'll find in general that many applications have people who'll want to read your innards. If you're a browser, your cookie jar is valuable; an email client, your email storage and address book.
> It is much easier to copy and sync files that store relevant information
It is easier to write such an application. It is harder to make such an application correct. To give a concrete example of where things can go wrong: Suppose I'm running my email client when the backup process is running. The backup process finishes copying the contents of my mail folder, and my email client gets a new message, which it dutifully files into that folder. This creates a new file in said folder, and also updates the cached metadata file. Now the backup process indexes the metadata file. Were I to try to restore from this backup, the resulting state is inconsistent, and the message may well be gone forever.