Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do caches in ehcache.xml inherit from defaultCache?

Tags:

ehcache

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)?

like image 868
Michael Piefel Avatar asked Jun 07 '12 12:06

Michael Piefel


People also ask

Is Ehcache in memory cache?

In this article, we will introduce Ehcache, a widely used, open-source Java-based cache. It features memory and disk stores, listeners, cache loaders, RESTful and SOAP APIs and other very useful features.

What is the use of Ehcache XML?

xml is included in the Ehcache distribution and can also be downloaded from http://ehcache.org/ehcache.xml. It contains comments to help you configure each element. Note that some elements documented in the sample Ehcache XML file pertain only to BigMemory and are not valid for the open-source version of Ehcache.

Is Ehcache persistent?

Open-source Ehcache offers a limited version of persistence, as noted in this document. Fast Restart provides enterprise-ready crash resilience with an option to store a fully consistent copy of the cache on the local disk at all times.


1 Answers

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.
like image 118
abhi.sanoujam Avatar answered Sep 19 '22 18:09

abhi.sanoujam