LibraryToggle FramesPrintFeedback
Name Default Value Description
maxElementsInMemory 1000 The numer of elements that may be stored in the defined cache
memoryStoreEvictionPolicy MemoryStoreEvictionPolicy.LFU

The number of elements that may be stored in the defined cache. The policy options include:

  • MemoryStoreEvictionPolicy.LFU—Least frequently used.

  • MemoryStoreEvictionPolicy.LRU—Least recently used.

  • MemoryStoreEvictionPolicy.FIFO—First in first out, ordered by creation time.

overflowToDisk true Specifies whether cache may overflow to disk.
eternal false Sets whether elements are eternal. If eternal, timeouts are ignored and the element is never expired.
timeToLiveSeconds 300 The maximum time between creation time and when an element expires. Is only used if the element is not eternal.
timeToIdleSeconds 300 The maximum amount of time between accesses before an element expires.
diskPersistent true Whether the disk store persists between restarts of the Virtual Machine. The default value is false.
diskExpiryThreadIntervalSeconds 120 The number of seconds between runs of the disk expiry thread. The default value is 120 seconds.
cacheManagerFactory null If you want to use a custom factory which instantiates and creates the EHCache, net.sf.ehcache.CacheManager, you must specify an instance of type, org.apache.camel.component.cache.CacheManagerFactory.
eventListenerRegistry null Camel 2.8: Sets a list of EHCache net.sf.ehcache.event.CacheEventListener for all new caches\- no need to define it per cache in EHCache xml config anymore. Type: org.apache.camel.component.cache.CacheEventListenerRegistry
cacheLoaderRegistry null Camel 2.8: Sets a list of org.apache.camel.component.cache.CacheLoaderWrapper that extends EHCache net.sf.ehcache.loader.CacheLoader for all new caches\- no need to define it per cache in EHCache xml config anymore. Type: org.apache.camel.component.cache.CacheLoaderRegistry
Header Description
CamelCacheOperation

The operation to be performed on the cache. The valid options are

  • CamelCacheGet

  • CamelCacheCheck

  • CamelCacheAdd

  • CamelCacheUpdate

  • CamelCacheDelete

  • CamelCacheDeleteAll

CamelCacheKey The cache key used to store the message in the cache. The cache key is optional if the CamelCacheOperation is CamelCacheDeleteAll.
[Important]Header changes in Camel 2.8

The header names and supported values have changed to be prefixed with CamelCache and use mixed case. This makes them easier to identify and keep separate from other headers. The CacheConstants variable names remain unchanged, just their values have been changed. Also, these headers are now being removed from the exchange after the cache operation is performed.

EHCache has its own statistics and management from JMX.

Here's a snippet on how to expose them via JMX in a Spring application context:

<bean id="ehCacheManagementService"
      class="net.sf.ehcache.management.ManagementService"
      init-method="init"
      lazy-init="false">
  <constructor-arg>
    <bean class="net.sf.ehcache.CacheManager" factory-method="getInstance"/>
  </constructor-arg>
  <constructor-arg>
    <bean class="org.springframework.jmx.support.JmxUtils" factory-method="locateMBeanServer"/>
  </constructor-arg>
  <constructor-arg value="true"/>
  <constructor-arg value="true"/>
  <constructor-arg value="true"/>
  <constructor-arg value="true"/>
</bean>

Of course you can do the same thing in straight Java:

ManagementService.registerMBeans(CacheManager.getInstance(), mbeanServer, true, true, true, true);

You can get cache hits, misses, in-memory hits, disk hits, size stats this way. You can also change CacheConfiguration parameters on the fly.

Comments powered by Disqus