You are here: Configuration > File Configuration > Storage > FileStorage

FileStorage

FileStorage is the base storage mechanism, providing the functionality of file access. The benefit of using FileStorage directly is in decreased memory consumption.

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
IStorage fileStorage = new FileStorage();
configuration.File.Storage = fileStorage;
IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
IOConfigurationExamples.cs: Using the pure file storage
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
Dim fileStorage As IStorage = New FileStorage()
configuration.File.Storage = fileStorage
Dim container As IObjectContainer = Db4oEmbedded.OpenFile(configuration, "database.db4o")
IOConfigurationExamples.vb: Using the pure file storage

Without cache, the file storage is significantly slower than with cache. Therefore this storage is normally used as underlying storage for other purposes. Typically it is used together with a CachingStorage on top of it:

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
IStorage fileStorage = new FileStorage();
IStorage cachingStorage = new CachingStorage(fileStorage, 128, 1024);
configuration.File.Storage = cachingStorage;
IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
IOConfigurationExamples.cs: Using a caching storage
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
Dim fileStorage As IStorage = New FileStorage()
Dim cachingStorage As IStorage = New CachingStorage(fileStorage, 128, 1024)
configuration.File.Storage = cachingStorage
Dim container As IObjectContainer = Db4oEmbedded.OpenFile(configuration, "database.db4o")
IOConfigurationExamples.vb: Using a caching storage