I've got a number of wealthy data structures (mainly trees) that I must persist to disk, meaning I not simply want to write these to disk however i desire a guarantee the data continues to be fully written and can survive a energy-lower.

Others appear to create methods to scribe wealthy data structures in flat database tables as research tables from parent to child nodes. This facilitates running SQL queries from the data however i don't have any need for your: Among the finest in order to save and load my trees.

The apparent option would be to keep everything like a blob within the database: just one entry possibly that contains a lengthy string. Is the fact that an abuse from the database or perhaps a suggested practice? Another solution may be to make use of an XML database? What are the options to databases which i ought to be thinking about?

Finally, I am carrying this out from F# so a turnkey solution for persisting data from .Internet could be ideal...

EDIT: Please be aware that formatting (e.g. serialization) does not matter when i can trivially convert between formats with F#. This really is about getting an acknowledgement that the write continues to be completed completely lower towards the non-volatile store (i.e. the disk platter) with no area of the written data continues to be locked in volatile store (e.g. an RAM cache) to ensure that I'm able to continue safe for the reason that understanding (e.g. by removing that old version from the data from disk).

A few of the constructors for .NET's FileStream class have a parameter of type FileOptions. Among the values for FileOptions is WriteThrough, which "Signifies the system should write through any intermediate cache and go straight to disk."

This will make sure that when your write operation (to a different file) returns, the information is devoted to disk and you will securely remove that old file.

You can do this via Serialization.

The .Internet Framework includes many built-in choices for serializing your computer data to disk, including using binary or XML-based formats. Detailed How-To articles are supplied within the MSDN Documentation.

To be able to do that, you'll need an origin which will help you to participate in a Transaction (generally, you would employ a TransactionScope.

Most databases will take part in a Transaction if your are contained. Disk procedures may also be handled with a Transaction, but you would need to perform some specific work to be able to put it to use insInternet.

Also, observe that this really is only accessible on Home windows Vista and then.

Should you go the database route, then you may keep serialized items in your trees inside a blob (or text, with respect to the serialization mechanism).

Note, you may also make use of the FILESTREAM functionality in SQL Server (2008 or more, In my opinion) to keep your files around the filesystem and gain the advantages of transactions in SQL Server.

I've not used db4o from F# before, but it is all about persisting CLR object graphs to disk inside a transactional manner. Whether it works together with records and discriminated unions, it could suit you.

Edit: I simply examined db4o 8. (.Internet 4 version) also it appears to deal with both record types and discriminated union hierarchies perfectly well.

Use XMLSerializer (System.Xml.Serialization).


It may instantly persist complex data structures according to their qualities, and you will use characteristics to manage the output, if you want: