This simplest example will create a new storage if no existing storage is found, if a existing storage is found it will be loaded (this is all done at line 2 in the example above).
In line 6 the current storage's content is printed.
Line 7 assigns some data to the storage, replacing existing data if there is some.
In line 8 everything gets stored.
The Root Instance
When using MicroStream, your entire database is accessed starting at a root instance. This instance is the root object of an object graph that gets persisted by the MicroStream storage logic. While the root instance can be of any type (for example just a collection or an array), it is a good idea to define an explicit root type specific for the application. In this simple example, it is a class called DataRoot, which wraps a single String.
The following code is all that is required to setup a an application backed by a MicroStream database. The application's convenience root instance is defined and an EmbeddedStorageManager instance, linked to the root, is created (and its database managing threads are started). This is a fully operational Java database application.
// Application-specific root instance
finalDataRoot root =newDataRoot();
// Initialize a storage manager ("the database") with the given directory.