關於maven項目的整合

說明:最近兩天在把手裏項目的框架扒下來,學着自己搭框架自己做,這裏做筆記記錄一下





1.使用ehcache爲項目設置緩存:

      1.將jar包導入到lib目錄下

       ehcache-core-2.5.2.jar

       ehcache-web-2.0.4.jar 主要針對頁面緩存

     

       2.    放到配置文件夾下

      ehcache.xml

      ehcache.xsd

     

      3.  ehcache.xml的參數詳解:

            <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
            monitoring="autodetect" dynamicConfig="true">
           <defaultCache maxElementsInMemory="10000" eternal="false"
            timeToIdleSeconds="7200" timeToLiveSeconds="7200"
            diskSpoolBufferSizeMB="30" diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU">
          </defaultCache>
           <cache name="portal" maxElementsInMemory="10000" eternal="false"
           timeToIdleSeconds="7200" timeToLiveSeconds="7200"
          diskSpoolBufferSizeMB="30" diskExpiryThreadIntervalSeconds="120"
          memoryStoreEvictionPolicy="LRU">
         </cache>
         </ehcache>


       參數:

        xsi:noNamespaceSchemaLocation:屬性用於引用沒有目標名稱空間的模式文檔。與xsi:schemaLocation屬性不同的是,xsi:noNamespaceSchemaLocation屬性的值是單一的值,只是用於指定模式文檔的位置。xsi:noNamespaceSchemaLocation屬性必須出現在它要驗證的任何元素和屬性之前。


         monitoring:監測

          name:緩存名稱。  

  1. maxElementsInMemory:緩存最大個數。  
  2. eternal:對象是否永久有效,一但設置了,timeout將不起作用。  
  3.  timeToIdleSeconds:設置對象在失效前的允許閒置時間(單位:秒)。僅當eternal=false對象不是永久有效時使用,可選屬性,默認值是0,也就是可閒置時間無窮大。  
  4. timeToLiveSeconds:設置對象在失效前允許存活時間(單位:秒)。最大時間介於創建時間和失效時間之間。僅當eternal=false對象不是永久有效時使用,默認是0.,也就是對象存活時間無窮大。  
  5.  overflowToDisk:當內存中對象數量達到maxElementsInMemory時,Ehcache將會對象寫到磁盤中。  
  6.  diskSpoolBufferSizeMB:這個參數設置DiskStore(磁盤緩存)的緩存區大小。默認是30MB。每個Cache都應該有自己的一個緩衝區。  
  7.   maxElementsOnDisk:硬盤最大緩存個數。  
  8.   diskPersistent:是否緩存虛擬機重啓期數據 Whether the disk store persists between restarts of the Virtual Machine. The default value is false.  
  9.     diskExpiryThreadIntervalSeconds:磁盤失效線程運行時間間隔,默認是120秒。  
  10.   memoryStoreEvictionPolicy:當達到maxElementsInMemory限制時,Ehcache將會根據指定的策略去清理內存。默認策略是LRU(最近最少使用)。你可以設置爲FIFO(先進先出)或是LFU(較少使用)。  
  11.   clearOnFlush:內存數量最大時是否清除。 

        




     


 






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章