Spring 3.0.5 MVC 基于注解ehcache.xml 配置

来源:互联网 发布:数据监测系统 编辑:程序博客网 时间:2024/05/16 09:39

Spring 3.0.5 MVC 基于注解ehcache.xml 配置(注意:spring 3.1.X和3.0.X的不一样)

缓存机制,spring 3.0.5 中ehcache配置方法很简单,其中缓存机制很细颗粒化,可以具体到把每个方式的返回值做缓存:

jar包 :cglib-2.2.jar,ehcache-spring-annotations-1.1.2.jar  ehcache-2.7.1.jar

web.xml配置

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring" xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd  http://www.springframework.org/schema/aop   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-3.0.xsd  http://www.springframework.org/schema/tx   http://www.springframework.org/schema/tx/spring-tx-3.0.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">

<!-- Spring 3.0.5 MVC 基于注解ehcache.xml 配置 start--><ehcache:annotation-driven cache-manager="ehCacheManager" />   <bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">         <property name="configLocation" value="classpath:ehcache.xml" />     </bean> <!-- ehcache.xml 配置      end -->
src下新建ehcache.xml
<?xml version="1.0" encoding="UTF-8"?><ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"monitoring="autodetect"><!-- <diskStore path="java.io.tmpdir" /> --><diskStore path="E:/cachetmpdir01"/><defaultCache maxElementsInMemory="10000" eternal="false"timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"maxElementsOnDisk="10000000" diskPersistent="false"diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /><cache name="testCache" maxElementsInMemory="10000"maxElementsOnDisk="1000" eternal="false" overflowToDisk="true"diskSpoolBufferSizeMB="20" timeToIdleSeconds="300" timeToLiveSeconds="600"memoryStoreEvictionPolicy="LFU" /><cache name="andCache" maxElementsInMemory="10000"maxElementsOnDisk="1000" eternal="false" overflowToDisk="true"diskSpoolBufferSizeMB="20" timeToIdleSeconds="300" timeToLiveSeconds="600"memoryStoreEvictionPolicy="LFU" /></ehcache>  



原创粉丝点击