码迷,mamicode.com
首页 > 系统相关 > 详细

Ehcache缓存

时间:2017-05-16 15:49:44      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:ehcache缓存

ehcache.xml中

<?xml version="1.0" encoding="UTF-8"?>

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">

    <diskStore path="java.io.tmpdir"/>

    <defaultCache

            maxElementsInMemory="10000"

            eternal="false"

            timeToIdleSeconds="120"

            timeToLiveSeconds="120"

            overflowToDisk="true"

            maxElementsOnDisk="10000000"

            diskPersistent="false"

            diskExpiryThreadIntervalSeconds="120"

            memoryStoreEvictionPolicy="LRU"

            />

    <cache name="vocCache"  

        maxElementsInMemory="1000"

        eternal="false"

        timeToIdleSeconds="30"

        timeToLiveSeconds="60"

        overflowToDisk="true"/>

  

basic.xml中               

<?xml version="1.0" encoding="UTF-8"?>

<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:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"

xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"  

xmlns:cache="http://www.springframework.org/schema/cache"  

xsi:schemaLocation="

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd

http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd

http://www.springframework.org/schema/cache  

    http://www.springframework.org/schema/cache/spring-cache-3.2.xsd  

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd

http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">

<cache:annotation-driven cache-manager="cacheManager"/>  

     <bean id="cacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">  

         <property name="configLocation" value="classpath:ehcache.xml"/>  

     </bean>  

     <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">  

         <property name="cacheManager" ref="cacheManagerFactory"/>  

     </bean>  

</beans>


serviceImpl中

@Cacheable(value="vocCache", key="‘aa‘")

public Map<String, Object> getAA() {

     return aa;

}


Ehcache缓存

标签:ehcache缓存

原文地址:http://yuanyi860829.blog.51cto.com/8028103/1926220

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!