美文网首页
spring + ehcache 基本配置

spring + ehcache 基本配置

作者: bbmm | 来源:发表于2018-05-08 12:09 被阅读5次

appcontent.xml
echache.xml

spring 中配置ehcache的 cacheFactory 和 cacheManager
<!-- 配置缓存 -->
    <cache:annotation-driven cache-manager="cacheManager"/>
    <bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">  
        <property name="configLocation" value="classpath:ehcache.xml"></property>  
    </bean>  
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">  
        <property name="cacheManager" ref="ehcache"></property>  
    </bean> 
1.value="xxx" xxx为ehcache.xml中配置的cache 的name 如下
<cache name="baseCache" maxElementsInMemory="0" 
        eternal="true"
        timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
        diskSpoolBufferSizeMB="100"
         maxElementsOnDisk="0"
        diskPersistent="false" 
        diskExpiryThreadIntervalSeconds="120"
        memoryStoreEvictionPolicy="LFU" />
2、key为这个方法返回结果放入ehcache中的key ,注意点#userID
为方法参数 'menu_user' 为key的自定义前缀,注意必须要加''负责会报错说这个key的el解析异常
在需要配置缓存的方法上增加@cacheable
 @Cacheable(value="baseCache" ,key="'menu_user_'+#userID")
        public List<String> GetUserMenu(String userID){
            return Aarray.asList("","");
}

相关文章

  • Hibernate Ehcache 配置

    hibernate 默认使用 ehcache 缓存策略ehcache 配置 hibernate 配置 Spring...

  • spring + ehcache 基本配置

    appcontent.xmlechache.xml

  • Mybatis缓存配置

    pom文件配置: spring加载ehcache配置文件 ehcache.xml: mybatis.xml开启缓存...

  • EhCache使用笔记

    1、为什么使用EhCache? 2、在maven+spring + ehcache整合配置 2.1、pom文件添加...

  • Spring的缓存机制

    Spring的缓存机制启用Spring缓存Spring内置缓存实现的配置EhCache缓存实现的配置使用@Cach...

  • Ehcache详解

    1 cacheManager 的构建 Spring + Ehcache的配置 在Spring项目中只要注入cach...

  • Ehcache结合Spring

    本章介绍Ehcache结合Spring实现服务层的缓存,其他还有数据层缓存和页面缓存。 添加依赖 spring配置...

  • Spring系列-ehcache配置

    Ehcache是现在最流行的纯Java开源缓存框架,配置简单、结构清晰、功能强大,最初知道它,是从Hibernat...

  • Spring Boot整合EhCache

    本文讲解Spring Boot与EhCache的整合。 1 EhCache简介 EhCache 是一个纯Java的...

  • 缓存:Ehcache集成

    ehcache.xml shiro-ehcache.xml (框架自带的xml) 配置类

网友评论

      本文标题:spring + ehcache 基本配置

      本文链接:https://www.haomeiwen.com/subject/yqbirftx.html