管理 Hibernate 的二級緩衝

來源:互聯網
上載者:User

標籤:style   blog   color   io   使用   ar   sp   資料   div   

<ehcache>    <!--          指定一個目錄:當 EHCache 把資料寫到硬碟上時, 將把資料寫到這個目錄下.    -->         <diskStore path="d:\\tempDirectory"/>    <!--          設定緩衝的預設資料到期策略     -->        <defaultCache        maxElementsInMemory="10000"        eternal="false"        timeToIdleSeconds="120"        timeToLiveSeconds="120"        overflowToDisk="true"        />       <!--             設定具體的具名快取的資料到期策略。每個具名快取代表一個快取區域           快取區域(region):一個具有名稱的緩衝塊,可以給每一個緩衝塊設定不同的緩衝策略。           如果沒有設定任何的快取區域,則所有被緩衝的對象,都將使用預設的緩衝策略。即:<defaultCache.../>           Hibernate 在不同的快取區域儲存不同的類/集合。            對於類而言,地區的名稱是類名。如:com.atguigu.domain.Customer            對於集合而言,地區的名稱是類名加屬性名稱。如com.atguigu.domain.Customer.orders       -->       <!--             name: 設定緩衝的名字,它的取值為類的全限定名或類的集合的名字            maxElementsInMemory: 設定基於記憶體的緩衝中可存放的對象最大數目                     eternal: 設定對象是否為永久的, true表示永不到期, 此時將忽略timeToIdleSeconds 和 timeToLiveSeconds屬性; 預設值是false           timeToIdleSeconds:設定對象空閑最長時間,以秒為單位, 超過這個時間,對象到期。當對象到期時,EHCache會把它從緩衝中清除。如果此值為0,表示對象可以無限期地                  處於空閑狀態。            timeToLiveSeconds:設定對象生存最長時間,超過這個時間,對象到期。如果此值為0,表示對象可以無限期地存在於緩衝中. 
                該屬性值必須大於或等於 timeToIdleSeconds 屬性值 overflowToDisk:設定基於記憶體的緩衝中的對象數目達到上限後,是否把溢出的對象寫到基於硬碟的緩衝中
--> <cache name="com.atguigu.hibernate.entities.Employee" maxElementsInMemory="1" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="true" /> <cache name="com.atguigu.hibernate.entities.Department.emps" maxElementsInMemory="1000" eternal="true" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" /></ehcache>

 

管理 Hibernate 的二級緩衝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.