2019独角兽企业重金招聘Python工程师标准>>>

首先导入ehcache-web.jar   ehcache-core.jar

web.xml配置

<filter>  
    <filter-name>PageCacheFilter</filter-name>  
        <filter-class>net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter  
    </filter-class>  
  </filter>  
  <filter-mapping>  
    <filter-name>PageCacheFilter</filter-name>  
    <url-pattern>*.html</url-pattern>  <!--缓存html文件-->
  </filter-mapping>

ehcache配置

<?xml version="1.0" encoding="UTF-8"?>
 <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
      <diskStore path="java.io.tmpdir" />
      <defaultCache eternal="false"
                    maxElementsInMemory="1000"
                    overflowToDisk="false"
                    diskPersistent="false"
                    timeToIdleSeconds="0"
                    timeToLiveSeconds="600"
                    memoryStoreEvictionPolicy="LRU"/>

<cache name="departCache"
             eternal="false"
             maxElementsInMemory="100"
             overflowToDisk="false"
             diskPersistent="false"
             timeToIdleSeconds="0"
             timeToLiveSeconds="300"
             memoryStoreEvictionPolicy="LRU"/>
      <cache name="SimplePageCachingFilter"
             eternal="false"
             maxElementsInMemory="100"
             overflowToDisk="false"
             diskPersistent="false"
             timeToIdleSeconds="0"
             timeToLiveSeconds="30"
             memoryStoreEvictionPolicy="LRU"/>

</ehcache>

spring配置<!--如果只是为了缓存页面 并不需要spring -->

<!-- 引用ehCache的配置 -->    
        <bean id="defaultCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">    
          <property name="configLocation">    
            <value>classpath:ehcache.xml</value>    
         </property>    
        </bean>
         
          <!-- 定义ehCache的工厂,并设置所使用的Cache name -->    
        <bean id="ehCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">    
          <property name="cacheManager">    
            <ref local="defaultCacheManager"/>    
          </property>    
          <property name="cacheName">    
              <value>departCache</value>    
          </property>    
        </bean>

转载于:https://my.oschina.net/chenliyong/blog/727311

spring整合ehcache相关推荐

  1. Spring,ehcache整合报错

    摘要:在做Spring整合ehcache配置的时候出现了下面的错误,提示如下:java.lang.ClassNotFoundException: org.springframework.cache.e ...

  2. springboot整合jpa_SpringBoot与SpringDataJPA整合 Ehcache

    1. SpringBoot整合Spring Data JPA步骤-(上) (1) 创建一个Maven的jar工程. (2)修改POM文件添加Web启动器,Thymeleaf启动器,Spring Dat ...

  3. Spring Boot2 整合 Ehcache

    用惯了 Redis ,很多人已经忘记了还有另一个缓存方案 Ehcache ,是的,在 Redis 一统江湖的时代,Ehcache 渐渐有点没落了,不过,我们还是有必要了解下 Ehcache ,在有的场 ...

  4. Spring和Ehcache整合详解

    Spring和Ehcache整合详解 一.官方主页 Spring Cache 二.概述 EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点. Spring 提供了对缓存功能的抽象: ...

  5. Spring Boot整合EhCache实现缓存操作.md

    在Spring Boot中开启EhCache非常简单,只需要在工程中加入ehcache.xml配置文件并在pom.xml中增加ehcache依赖,框架只要发现该文件,就会创建EhCache的缓存管理器 ...

  6. Struts2、Hibernate、Spring整合所需要的jar包

    Struts2.Hibernate.Spring整合所需要的包: Struts2: struts2-core-2.0.14.jar  -- Struts2的核心包. commons-logging-1 ...

  7. mybatis的缓存机制(一级缓存二级缓存和刷新缓存)和mybatis整合ehcache

    1      查询缓存 1.1  什么是查询缓存 mybatis提供查询缓存,用于减轻数据压力,提高数据库性能. mybaits提供一级缓存,和二级缓存. 一级缓存是SqlSession级别的缓存.在 ...

  8. shiro教程:整合ehcache缓存

    这个是在ssm的基础上再去整合shiro和ehcache的,整合ehcache主要是为了减少后台shiro拦截的次数,因为如果我们不使用缓存的话,后台shiro的认证和授权的拦截器就会反复的进行拦截, ...

  9. mybatis教程--查询缓存(一级缓存二级缓存和整合ehcache)

    查询缓存 1 缓存的意义 将用户经常查询的数据放在缓存(内存)中,用户去查询数据就不用从磁盘上(关系型数据库数据文件)查询,从缓存中查询,从而提高查询效率,解决了高并发系统的性能问题. 2 mybat ...

最新文章

  1. VC:CString用法整理(转载)
  2. 如果三国中有5G网,刘关张该这样拜把子!
  3. a*算法的时间复杂度_从经典算法题看时间复杂度
  4. SAP RETAIL 商品主数据里影响自动补货结果的几个参数 I
  5. Mac下安装MariaDB(自用备忘)
  6. 【Linux】一步一步学Linux——dpkg-deb命令(270)
  7. List转DataTable(反射)
  8. 无法访问虚拟机tomcat网页
  9. jzoj1295-设计【差分约束系统,最短路】
  10. Java –远景JDK 8
  11. java写hive自定义函数_hive自定义函数的实现和执行
  12. 打造“5G+IoT”生态,共创产业繁荣沃土
  13. C语言程序书写中 每行必须有分号,石家庄铁道大学C语言程序设计习题集.pdf
  14. SQLMAP 脱库过程(get请求)
  15. 威feng网站的aes算法破解
  16. kubernetes 系列之 - 暴露运行的服务端口
  17. Juniper Junos设置3层接口
  18. 设计模式在美团外卖营销业务中的实践
  19. 南阳师范学院计算机科学与技术在哪个校区,2021年南阳师范学院有几个校区,大一新生在哪个校区...
  20. 计算机组成原理——存储地址与边界对齐

热门文章

  1. 开机按F1才能进入(启动)系统的解决方案
  2. 邮件服务器IMail教程(2)
  3. Linux常用正则表达式
  4. ubuntu14安装tensorflow并测试
  5. 剑指OFFER之用两个栈实现队列(九度OJ1512)
  6. [转载]c#委托事件简单例子
  7. ASP.NET MVC Model绑定(五)
  8. 【C++实现】HeadFirst策略模式设计模式
  9. 通过命令行创建MAVEN多模块项目
  10. 用一句位运算判断两个整数的大小并返回较大者