Archive for category ehCache

Configure EhCache+Spring


Inside Spring-Beans.xml

<beans xmlns=”http://www.springframework.org/schema/beans&#8221;
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
xmlns:util=”http://www.springframework.org/schema/util&#8221;
xmlns:ehcache=”http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring&#8221;
xsi:schemaLocation=”http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd”&gt;

<ehcache:annotation-driven cache-manager=”ehCacheManager” />

<bean id=”ehCacheManager”>
<property name=”configLocation” value=”classpath:spring/ehcache.xml” />
</bean>

Inside ehcache.xml

<ehcache>
<defaultCache
maxElementsInMemory=”500″
eternal=”true”
overflowToDisk=”false”
memoryStoreEvictionPolicy=”LFU” />

<cache name=”testCache”
maxElementsInMemory=”50″
timeToLiveSeconds=”900″
eternal=”false”
overflowToDisk=”false”
memoryStoreEvictionPolicy=”LFU” />

</ehcache>

POM

<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.1.3</version>
</dependency>

Leave a comment