0 votes
asked in MicroStream by (520 points)

Suppose I have the following root object:

private Map<String, Container> root = new HashMap<>();

Will the whole map be loaded when the storage is started?
If yes, how to prevent loading the values of the root map on startup?

Or should I have  the Container wrapped by Lazy?

private Map<String, Lazy<Container>> root = new HashMap<>();

 

1 Answer

0 votes
answered by (9.7k points)
selected by
 
Best answer

Hello,

You are right, in the first case the whole Map will be loaded on startup. The second case skips loading the Container Objects on startup. If this would be a benefit depends on the size of the map and the size of the Container objects.

As an alternative you could also load the whole map lazy.
This is easily done by using custom root object like:

public class MyStorageRoot 
{
    public Lazy<Map<String, Container>> lazyLoadedMap = Lazy.Reference(new HashMap<>());
    public MyObject                     loadedOnStartup;
}

 

Best regards

Notes: Every question must be a separate forum post. Headline: Formulate your question shortly and precisely. Thank you!
Powered by Question2Answer
...