您的位置:首页 > 其它

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: