iBATIS 缓存不会在给定语句上刷新
我正在使用 iBatis 进行数据库交互。 最近我试图通过配置缓存来提高一些静态数据获取的性能。 缓存已配置并正常工作,但问题在于每当该数据发生任何插入/更新/删除时都会刷新缓存数据。 我对类别表做了以下配置,
<cacheModel type="LRU" id="categoryCache" readOnly="true" serialize="false">
<flushOnExecute statement="insertCategory"/>
<flushOnExecute statement="updateCategory"/>
<flushOnExecute statement="deleteCategory"/>
<property name="size" value="1000"/>
</cacheModel>
<insert id="insertCategory"
parameterClass="com.uniplas.entity.master.beans.CategoryVO">
insert into categories (code, description)
values(#code:VARCHAR#,#description:VARCHAR#)
</insert>
<update id="updateCategory"
parameterClass="com.uniplas.entity.master.beans.CategoryVO">
update categories set description=#description:VARCHAR# where code=#code:VARCHAR#
</update>
<delete id="deleteCategory"
parameterClass="com.uniplas.entity.master.beans.CategoryVO">
delete from categories where code=#code:VARCHAR#
</delete>
<select id="selectCategory" resultMap="categoryResult"
parameterClass="java.util.Map" cacheModel="categoryCache">
select * from categories where 1=1
<dynamic>
<isNotEmpty property="categoryVO.code">
and code like #categoryVO.code:VARCHAR#
</isNotEmpty>
<isNotEmpty property="categoryVO.description">
and description like
#categoryVO.description:VARCHAR#
</isNotEmpty>
<isNotEmpty property="orderBy">
order by $orderBy$
</isNotEmpty>
</dynamic>
</select>
现在的问题是,即使执行 insertCategory / updateCategory / deleteCategory 语句中的任何一个,缓存也不会被刷新。 它维护插入/更新/删除之前选择的任何数据!
请让我知道我哪里出错了。
I am using iBatis for my database interaction. Lately I am trying to improve performance of some static data fetches by configuring caching. The chache got configured and worked properly however the problem is in flushing of cache data whenever any insert/update/delete happens to that data. I did following configuration for category table,
<cacheModel type="LRU" id="categoryCache" readOnly="true" serialize="false">
<flushOnExecute statement="insertCategory"/>
<flushOnExecute statement="updateCategory"/>
<flushOnExecute statement="deleteCategory"/>
<property name="size" value="1000"/>
</cacheModel>
<insert id="insertCategory"
parameterClass="com.uniplas.entity.master.beans.CategoryVO">
insert into categories (code, description)
values(#code:VARCHAR#,#description:VARCHAR#)
</insert>
<update id="updateCategory"
parameterClass="com.uniplas.entity.master.beans.CategoryVO">
update categories set description=#description:VARCHAR# where code=#code:VARCHAR#
</update>
<delete id="deleteCategory"
parameterClass="com.uniplas.entity.master.beans.CategoryVO">
delete from categories where code=#code:VARCHAR#
</delete>
<select id="selectCategory" resultMap="categoryResult"
parameterClass="java.util.Map" cacheModel="categoryCache">
select * from categories where 1=1
<dynamic>
<isNotEmpty property="categoryVO.code">
and code like #categoryVO.code:VARCHAR#
</isNotEmpty>
<isNotEmpty property="categoryVO.description">
and description like
#categoryVO.description:VARCHAR#
</isNotEmpty>
<isNotEmpty property="orderBy">
order by $orderBy$
</isNotEmpty>
</dynamic>
</select>
Now the problem is that even if any of insertCategory / updateCategory / deleteCategory statement is executed, the cache does not get flushed. It maintains the data whatver was selected prior to insert / update / delete !
Please let me know where I am going wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将缓存设置为 readOnly="false" ——来自文档:
Try setting your cache to readOnly="false" -- From the documentation: