【发布时间】:2016-12-17 17:18:15
【问题描述】:
我正在使用带有 ehcache 的 mybatis 来缓存查询结果以避免 DB 命中频率。我的问题是:如果选择查询返回零记录,那么 ehcache 会缓存该记录并始终返回零作为结果,即使在此查询执行后插入的有效记录也是如此。
如果查询仅返回零记录,任何人都可以建议如何配置 ehcache 以不缓存。
<mapper namespace="org.test">
<cache type="org.mybatis.caches.ehcache.EhcacheCache">
<property name="eternal" value="false" />
<property name="maxEntriesLocalHeap" value="10000"/>
<property name="maxEntriesLocalDisk" value="10000000"/>
<property name="timeToIdleSeconds" value="3600" />
<property name="timeToLiveSeconds" value="3600" />
<property name="memoryStoreEvictionPolicy" value="LRU" />
<property name="statistics" value="true" />
</cache>
<select id="userInfo" parameterType="map" resultMap="userInfoList" useCache="true">
SELECT USERNAME,USERID FROM TEST_TABLE
</select>
【问题讨论】: