In earlier versions of Ehcache you where able to define a default-cache configuration, which will be applied to caches created programmatically. Since Ehcache3 they changed the configuration xsd quite a lot and there doesn't seem to be an equivalent to defaultCache anymore - or at least, I cannot find it anywhere.
For example old configuration:
<ehcache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="false">
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToLiveSeconds="120"
overflowToDisk="false" />
</ehcache>
I tried it with the following configuration, but I don't know if that is working or not or if I can just remove and ignore it. I guess I can ignore it because when I boot the application I don't get any warnings that ehcache cannot find a configuration for a specific cache.
New configuration:
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="
http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core.xsd">
<cache alias="default">
<expiry>
<ttl>120</ttl>
</expiry>
<heap>10000</heap>
</cache>
</config>
The reason why I'm using alias="default"
is because in this documentation: ehcache.xml they mentioned that the internal name for defaultCache is "default". Quote:
Default Cache configuration. These settings will be applied to caches created programmatically using CacheManager.add(String cacheName). This element is optional, and using CacheManager.add(String cacheName) when its not present will throw CacheException The defaultCache has an implicit name "default" which is a reserved cache name.
So the question is, is there an equivalent for defaultCache in Ehcache3 or can I just remove it?