Related Documentation : Integrations : Using Ehcache with OpenJPA : Installation and Configuration
Installation and Configuration
Installation
Ehcache easily integrates with the OpenJPCA persistence framework from Apache.
To use OpenJPA, add a Maven dependency for ehcache-openjpa.
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-openjpa</artifactId>
<version>0.1</version>
Or, download from http://ehcache.org/downloads/catalog.
Configuration
For enabling Ehcache as second-level cache, the persistence.xml file should include the following configurations:
<property name="openjpa.Log" value="SQL=TRACE" />
<property name="openjpa.QueryCache" value="ehcache" />
<property name="openjpa.DataCache" value="true"/>
<property name="openjpa.RemoteCommitProvider" value="sjvm"/>
<property name="openjpa.DataCacheManager" value="ehcache" />
The ehcache.xml file can be configured as shown in this example:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false"
monitoring="autodetect"
dynamicConfig="true" name="TestCache">
<diskStore path="/path/to/store/data"/>
<defaultCache
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
memoryStoreEvictionPolicy="LRU">
<persistence strategy="localTempSwap"/>
</defaultCache>
<cache name="com.terracotta.domain.DataTest"
maxEntriesLocalHeap="200"
eternal="false"
timeToIdleSeconds="2400"
timeToLiveSeconds="2400"
memoryStoreEvictionPolicy="LRU">
</cache>
<cache name="openjpa"
maxEntriesLocalHeap="20000"
eternal="true"
memoryStoreEvictionPolicy="LRU">
</cache>
<cache name="openjpa-querycache"
maxEntriesLocalHeap="20000"
eternal="true"
memoryStoreEvictionPolicy="LRU">
</cache>
<cacheManagerPeerListenerFactory
class="org.terracotta.ehcachedx.monitor.probe.ProbePeerListenerFactory"
         properties="monitorAddress=localhost, monitorPort=9889,
         memoryMeasurement=true" />
</ehcache>
Copyright © 2010-2015 Software AG, Darmstadt, Germany.

Product Logo |   Feedback