As said in EhCache documentation:
In practice this means that persistent in-memory cache will start up with all of its elements on disk. [...] So, the Ehcache design does not load them all into memory on start up, but lazily loads them as required.
I would like that the memory cache start up will all its elements in memory, how can I achieve that?
The reason for this is that our website performs a lot of access to the cache, so the first time we visit the website it has very bad response time.
I am assuming that all the cached elements are in the DiskStore and you want them to be in-memory as soon as the application is started. In anycase using BootStrapCacheLoader and BootstrapCacheLoaderFactory should be helpful.
I am just giving idea where we load DiskStore into memeory after the application is started
You can implement BootstrapCacheLoader which will load the cache elements as below. Definition of the method BootstrapCacheLoader.load(Ehcache cache) can be
Above method reads the element from DiskCache, Removes it and Puts it back so that it stays in the memory and disk version is removed.
Implement BootstrapCacheLoaderFactory so that
You can define cache configuration as below with CustomBootstrapCacheLoaderFactory as below