java web項目裡ehcache.xml介紹

來源:互聯網
上載者:User

複製代碼 代碼如下:<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false"
monitoring="autodetect" dynamicConfig="true">

<diskStore path="java.io.tmpdir" />

<defaultCache maxElementsInMemory="10000" eternal="true"
overflowToDisk="true"
maxElementsOnDisk="10000000" diskPersistent="false"
diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />

</ehcache>

name:緩衝名稱。
maxElementsInMemory:緩衝最大個數。
eternal:對象是否永久有效,一但設定了,timeout將不起作用。
timeToIdleSeconds:對象在失效前的允許閑置時間(秒)。當eternal=false時使用,可選屬性,預設值是0,也就是可閑置時間無窮大。
timeToLiveSeconds:對象在失效前允許存活時間(秒).最大時間介於建立時間和失效時間之間.當eternal=false時使用,預設是0,也就是對象存活時間無窮大。
overflowToDisk:當記憶體中對象數量達到maxElementsInMemory時,Ehcache將對象寫到磁碟中。
diskSpoolBufferSizeMB:這個參數設定DiskStore(磁碟緩衝)的緩衝區大小。預設是30MB。每個Cache都應該有自己的一個緩衝區。
maxElementsOnDisk:硬碟最大緩衝個數。
diskPersistent:是否緩衝虛擬機器重啟期資料,預設值為false。
diskExpiryThreadIntervalSeconds:磁碟失效線程已耗用時間間隔,預設是120秒。
memoryStoreEvictionPolicy:當達到maxElementsInMemory限制時,Ehcache將會根據指定的策略去清理記憶體。預設策略是LRU(最近最少使用)。你可以設定為FIFO(先進先出)或是LFU(較少使用)。
clearOnFlush:記憶體數量最大時是否清除。

<diskStore>表示當記憶體緩衝中對象數量超過類設定記憶體緩衝數量時,將緩衝對象寫到硬碟,path=”java.io.tmpdir”表示把資料寫到這個目錄下。Java.io.tmpdir目錄在運行時會根據相對路徑產生。
<defaultCache>表示設定緩衝的預設資料到期策略。
<cache>表示設定用具體的具名快取的資料到期策略。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.