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.

About

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

<dependencies>
    <dependency>
        <groupId>com.foreach.across.modules</groupId>
        <artifactId>ehcache-module</artifactId>
        <version>1.0.1.M1</version>
    </dependency>
</dependencies>

1.2. Module dependencies

Module Type Description

DebugWebModule

optional

Enables the debug controllers.

1.3. Module settings

Property Type Description Default

ehcacheModule.configurationResource

Resource.class

Ehcache XML resource file.

classpath:ehcache.xml

ehcacheModule.configurationObject

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

Configuration class instance or class name.

null

ehcacheModule.cacheManagerName

String.class

Name of the CacheManager instance.

null

ehcacheModule.cacheManagerIsShared

boolean

Should the created CacheManager be shared at the ClassLoader level.

true

2. What’s new in this version?

1.0.1.M1

  • The properties prefix has been changed from ehcache. to ehcacheModule.

1.0.0.RELEASE

Initial public release available on Maven central.

3. Cache manager

EhcacheModule requires a valid ehcache configuration to be specified, either via an xml resource (ehcacheModule.configurationResource property) or a net.sf.ehcache.config.Configuration instance (ehcacheModule.configurationObject 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.

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

4. Debug web controllers

Note
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.