s2sh ehcache页面部分缓存

ehcache做页面部分缓存,配置有点麻烦,操作也有点复杂,不过感觉还是很好用。

首先看web.xml配置:

    <!--ehcache web page cache -->  
         <filter>  
        <filter-name>fragmentCache</filter-name>  
        <filter-class>net.sf.ehcache.constructs.web.filter.SimplePageFragmentCachingFilter  
        </filter-class>  
         <init-param>  
          <param-name>suppressStackTraces</param-name>  
          <param-value>false</param-value>  
        </init-param>  
        <init-param>  
          <param-name>cacheName</param-name>  
          <param-value>fragmentCache</param-value>  
        </init-param>  
          
      </filter>  
      
        <!--  
            This is a filter chain. They are executed in the order below. Do not  
            change the order.  
        -->  
      
         <filter-mapping>  
        <filter-name>fragmentCache</filter-name>  
        <url-pattern>/WEB-INF/pages/tour/tourDetailBody.jsp</url-pattern>  
        <dispatcher>INCLUDE</dispatcher>   
        </filter-mapping>  
ehcache.xml
    <?xml version="1.0" encoding="UTF-8"?>  
    <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xsi:noNamespaceSchemaLocation="../../main/config/ehcache.xsd">  
      
        <diskStore path="java.io.tmpdir" />  
      
        <defaultCache   
            maxElementsInMemory="10"   
            eternal="false"  
            timeToIdleSeconds="5"   
            timeToLiveSeconds="10"   
            overflowToDisk="true" />  
        <!--  
            maxElementsInMemory="10"内存中的最大页面对象   
            eternal="false"  
            timeToIdleSeconds="120" timeToIdleSeconds ,多长时间不访问该缓存,那么ehcache就会清除该缓存。   
            timeToLiveSeconds="240" timeToLiveSeconds,缓存的存活时间,从开始创建的时间算起。  
            overflowToDisk="true" 是否写入硬盘  
        -->  
        <!-- Page and Page Fragment Caches -->  
      
        <cache name="fragmentCache"   
            maxElementsInMemory="10"   
            eternal="false"  
            timeToIdleSeconds="10000"   
            timeToLiveSeconds="10000"   
            overflowToDisk="true">  
        </cache>  
    </ehcache>  

1,下载EhCache web版  http://ehcache.org/downloads/catalog  注意下载web版。

2,解压 将ehcache-web-2.0.3.jar 、ehcache-core-2.3.0.jar  拷入lib中。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值