• 网站首页添加缓存--------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>

  • 相关阅读:
    Spring——AOP
    Spring——事务管理
    分布式和集群的区别
    数据结构——二叉树
    数据结构——队列
    C语言 一维数组叠加为二维数组样例
    C语言一维数组转换为二维数组
    C语言 二维数组复制、清零及打印显示
    C语言 动态创建二维数组
    java byte【】数组与文件读写(增加新功能)
  • 原文地址:https://www.cnblogs.com/chizizhixin/p/5383352.html
Copyright © 2020-2023  润新知