I have this configuration for ehCache:
<ehcache>
<defaultCache
name="defaut"
maxElementsInMemory="5"
eternal="false"
timeToIdleSeconds="20"
timeToLiveSeconds="20"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
How can I get access to default cache of EhCache?
CacheManager.getInstance().getCache("default"); // returns null
My understanding is that the “default cache” is actually a template for new caches that get created, rather than being a specific named cache.
CacheManager.getCachewill only return a cache instance if it has already been created, so you’ll need to tell it to create a new one, using something likeaddCacheIfAbsent(). The name doesn’t matter, it will be created on demand using the default cache settings.