ibatis缓存优化
2015-11-24 20:15
405 查看
下面是查询用户缓存的ibatis语句,该语句用来查询最新的8个用户的信息,并缓存在数据库里面,当用户缓存有这8个用户数据信息后,下次
用户再去取这8个用户,就不用去执行这条sql语句了,而是直接从缓存里面去读取,这样可以大大提高查询数据库访问的效率
<cacheModel id="user-LastPub8-cache" type="LRU" readOnly="true">
<flushInterval hours="24"/>
<flushOnExecute statement="deleteUser"/>
<flushOnExecute statement="addUser"/>
<property name="size" value="8" />
</cacheModel>
<select id="getLastUser8" resultClass="User" cacheModel="user-LastPub8-cache">
<![CDATA[
select * from user order by lastupdate desc limit 8
]]>
</select>
用户再去取这8个用户,就不用去执行这条sql语句了,而是直接从缓存里面去读取,这样可以大大提高查询数据库访问的效率
<cacheModel id="user-LastPub8-cache" type="LRU" readOnly="true">
<flushInterval hours="24"/>
<flushOnExecute statement="deleteUser"/>
<flushOnExecute statement="addUser"/>
<property name="size" value="8" />
</cacheModel>
<select id="getLastUser8" resultClass="User" cacheModel="user-LastPub8-cache">
<![CDATA[
select * from user order by lastupdate desc limit 8
]]>
</select>
相关文章推荐
- 黑马程序员——C语言——数组
- EEG 学习记录
- 【人月神话】第二章:人月神话
- 家庭作业(更新中)
- Android应用启动优化:一种DelayLoad的实现和原理
- PopupWindow
- Java反射机制简介
- Linux.BackDoor.Gates/Chikdos Attack And Defense Analysis
- 我的余弦相似性,基于TFIDF结果
- 日志分析系统
- 如何实现 TreeView Items 全部展开和全部收缩(WPF)
- android 位移、缩放动画
- POJ2387 Til the Cows Come Home(SPFA + dijkstra + BallemFord 模板)
- uva 120 C - Stacks of Flapjacks
- 如何实现 TreeView Items 全部展开和全部收缩(WPF)
- 第二个Sprint冲刺第二天
- 读其他博客有感~
- Winform 子线程更新 控件
- css杂记
- 获得 1000 个赞的程序员高薪职业建议