Using CachedIoAdapter

CachedIoAdapter can be set up using the following code:

c#: 

delegateAdapter = new RandomAccessFileAdapter();

Db4oFactory.Configure().Io(new CachedIoAdapter(delegateAdapter));

VB: 

Dim delegateAdapter As RandomAccessFileAdapter = new RandomAccessFileAdapter();

Db4oFactory.Configure().Io(new CachedIoAdapter(delegateAdapter));

This will create 64 pages in memory of 1024 bytes each, resulting in 64 kB of memory available for caching.

You can customize the amount of available memory using:

c#: 

Db4oFactory.Configure().Io(new CachedIoAdapter(delegateAdapter, page_size, page_count));

VB: 

Db4oFactory.Configure().Io(new CachedIoAdapter(delegateAdapter, page_size, page_count));

Optimal cache size depends on many factors (application design, system resources etc) and will show different results for different disc access operations (read/write). The best way to find an optimal solution is to experiment with different page sizes and counts. Too little cache memory will result in decrease of performance, too much of it will unnecessary occupy your system resources. Note that all the caching pages are allocated in the memory on CachedIoAdapter creation and are not released while CachedIoAdapter is in use. Effectively, you can only release this memory closing the database file and switching back to the default RandomAccessFileAdapter.