zoukankan      html  css  js  c++  java
  • 网站首页添加缓存--------ehcache的简单使用

    1、首先把jar包放g以lib目录下ehcache-core-2.4.3.jar,ehcache-web-2.0.4.jar

    2、在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="false" dynamicConfig="false">
        <diskStore path="java.io.tmpdir/ehcache"/>
        <cache name = "SimplePageCachingFilter"
               maxElementsInMemory = "10"
               maxElementsOnDisk = "10"
               eternal = "false"
               overflowToDisk = "true"
               diskSpoolBufferSizeMB = "20"  
               timeToIdleSeconds = "300"
               timeToLiveSeconds = "300"
               memoryStoreEvictionPolicy = "LFU"
                >
            </cache>
        
    </ehcache>
    3、在web.xml中进行配置

         <welcome-file-list>
        <welcome-file>OnLoadServlet</welcome-file>
      </welcome-file-list>

    <filter>
            <filter-name>indexCacheFilter</filter-name>
            <filter-class>net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>indexCacheFilter</filter-name>
            <url-pattern>/OnLoadServlet</url-pattern>
        </filter-mapping>

     <servlet>
        <servlet-name>OnLoadServlet</servlet-name>
        <servlet-class>com.dianzhi.qiantai.servlet.OnLoadServlet</servlet-class>
      </servlet>

     <servlet-mapping>
        <servlet-name>OnLoadServlet</servlet-name>
        <url-pattern>/OnLoadServlet</url-pattern>
      </servlet-mapping>

  • 相关阅读:
    笔记类产品会不会衰落?
    ios 性能优化概述
    一个简单的旋转加载动画设计的思路
    常用算法的C++实现
    [转]解决Ionic2 innerHTML 无法嵌入HTML
    How to debug an Angular 2 application with Chrome and VS Code
    Angularjs2-下拉列表实现(父子组件通信)
    Angular 2 HTTP Requests with Observables
    Ionic2 beta8后更新的内容
    ionic2中如何使用自动生成器
  • 原文地址:https://www.cnblogs.com/chizizhixin/p/5383352.html
Copyright © 2011-2022 走看看