Reputation: 19998
If I have the following configuration:
<defaultCache timeToIdleSeconds="120"
timeToLiveSeconds="120" />
<cache name="test"
timeToLiveSeconds="300" />
What will be the value of timeToIdleSeconds
for the cache test
? Will it be inherited from the default cache, and thus be equal to 120, or will it take the default value as given in the manual, which is 0 (infinity)?
Upvotes: 14
Views: 7369
Reputation: 1
private Ehcache cloneDefaultCache(final String cacheName) {
if (defaultCache == null) {
return null;
}
Ehcache cache;
try {
cache = (Ehcache) defaultCache.clone();
} catch (CloneNotSupportedException e) {
throw new CacheException("Failure cloning default cache. Initial cause was " + e.getMessage(), e);
}
if (cache != null) {
cache.setName(cacheName);
}
return cache;
}
Method
cloneDefaultCache(String)
Found usages (2 usages found)
Library (2 usages found)
Unclassified usage (2 usages found)
Maven: net.sf.ehcache:ehcache-core:2.6.11 (2 usages found)
net.sf.ehcache (2 usages found)
CacheManager (2 usages found)
addCache(String) (1 usage found)
1173 Ehcache clonedDefaultCache = cloneDefaultCache(cacheName);
addCacheIfAbsent(String) (1 usage found)
1857 Ehcache clonedDefaultCache = cloneDefaultCache(cacheName);
Upvotes: 0
Reputation: 301
The timeToIdleSeconds will be default value and not inherit from "defaultCache". The "defaultCache" is a bit misnomer/misleading, in the sense that it does not provide "defaults" for every cache, but its just a way of specifying config for caches that can/are added dynamically - using cacheManager.addCache(String cacheName).
From http://www.ehcache.org/ehcache.xml, documentation for that tag reads
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.
Upvotes: 15