簡體   English   中英

ehcache-永久緩存

[英]ehcache - permanent caching

我是Ehcache的初學者。

我正在嘗試通過mybatis xml來緩存SQL查詢結果,而ehcache會將其結果緩存在查詢中,但是一旦操作完成,即使相同的JVM實例正在運行,也會清除緩存的數據。

誰能建議在JVM終止之前如何在磁盤/內存中存儲緩存?

mybatis-mapper.xml代碼段

<cache type="org.mybatis.caches.ehcache.EhcacheCache">
    <property name="eternal" value="false" />
    <property name="maxElementsInMemory" value="100000" />
    <property name="timeToIdleSeconds" value="3600" />
    <property name="timeToLiveSeconds" value="3600" />
    <property name="memoryStoreEvictionPolicy" value="LFU" />
    <property name="statistics" value="true" />
</cache>

.....

您正在尋找的是Ehcache Persistence

不是MyBatis-Ehcache橋的專家。 但是從您的配置示例中,假設您永遠不希望到期,請進行以下更改:

  • eternal屬性設置為true
  • 刪除兩個timeToXXX屬性

這將確保過期不會觸發。 請注意,盡管如此,高速緩存仍然可以退出以控制資源消耗。

為了解決此問題,我們需要在mapper.xml中明確提及以下屬性:1)selectCache操作的useCache =“ true”和flushCache =“ false” 2)所有插入/更新的flushCache =“ false” /刪除操作

示例代碼段:-

<select id="getTestData" parameterType="map" resultMap="testDtls"  useCache="true" flushCache="false" >

<insert id="insertTestData" parameterType="map" flushCache="false" >

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM