下面是查詢用戶緩存的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>