我是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>.
发布于 2016-05-13 05:07:46
你要找的是Ehcache Persistence
发布于 2016-05-14 00:44:14
不是MyBatis - Ehcache桥的专家。但是,从您的配置示例中,假设您永远不想过期,请执行以下更改:
要设置为true
eternal属性的两个timeToXXX属性
这将确保过期永远不会被触发。但请注意,缓存仍然可以驱逐以控制资源消耗。
发布于 2016-07-12 19:12:22
为了解决这个问题,我们需要在您的mapper.xml中显式地提到以下属性1) select操作的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" >https://stackoverflow.com/questions/37197145
复制相似问题