Built-in db4o blob type helps you to get rid of the problems of byte[] array, though it has its own drawbacks.
+ Main database file stays a lot smaller.
+ Backups are possible over individual files.
+The BLOBs are accessible without db4o.
- Multiple files need to be managed .
- It is more difficult to move objects between db4o database files.
+ Big objects won't be loaded into memory as part of the activation process.
First, the blob storage location should be defined. If that value is not defined, db4o will use the default folder "blobs" in user directory.
IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); configuration.File.BlobPath = "myBlobDirectory";
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration() configuration.File.BlobPath = "myBlobDirectory"
There are two important operations on the blob type. The first one write a file into the db4o blob:
blob.ReadFrom(fileToStore);
blob.ReadFrom(fileToStore)
And then there's the operation which .loads the db4o blob into a new file.
blob.WriteTo(file);
blob.WriteTo(file)
The db4o blob-type has a status attached to it. This status tells you if the blob-file all ready has been transferred:
while (blob.GetStatus() > Status.Completed) { Thread.Sleep(50); }
While blob.GetStatus() > Status.Completed Thread.Sleep(50) End While