Copyright © 2014-2015
Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.


EhcacheModule provides support for Ehcache in other modules. It creates an Ehcache cache manager and hooks it up to the Spring CacheManager infrastructure. The module also provides debug web controllers for viewing cache statistics and flushing the caches.

1. General information

1.1. Artifact


1.2. Module dependencies

Module Type Description



Enables the debug controllers.

1.3. Module settings

Property Type Description Default



Ehcache XML resource file.



net.sf.ehcache.config.Configuration.class or String.class

Configuration class instance or class name.



Name of the CacheManager instance.




Should the created CacheManager be shared at the ClassLoader level.


2. What’s new in this version?


Initial public release available on Maven central.

3. Cache manager

EhcacheModule requires a valid ehcache configuration to be specified, either via an xml resource (ehcache.configuration.resource property) or a net.sf.ehcache.config.Configuration instance (ehcache.configuration property). Upon bootstrapping the cache manager will be created and available as a Spring CacheManager implementation.

EhcacheModule will also activate support for the cache related annotations in every module. This would be the equivalent of putting @EnableCaching in every module.

Modules should avoid wiring Ehcache beans directly but use the Spring cache abstraction layer.

4. Debug web controllers

Only available if DebugWebModule is present.

When active, EhcacheModule adds a section Cache overview to the debug menu. The debug web controller supports multiple Ehcache cache managers and offers the following functions for each cache manager:

  • see cache statistics

  • browse individual cache items

  • flush caches either individually or per cache manager

  • calculate cache heap size

  • view remote RMI peers if RMI-based cache distribution is enabled

Calculating cache heap size

Apart from the actual heap size the debug controllers attempt to predict the maximum heap size using linear interpolation. All heap size values should be considered an estimation as they cannot always be calculated correctly.