ibatis缓存

本文介绍了两种缓存模型:LRU(最近最少使用)和FIFO(先进先出)。LRU适用于保留最常使用的数据,而FIFO则适用于简单地替换旧数据。文中详细解释了如何配置这些缓存策略,包括设置缓存大小、刷新间隔及触发刷新操作的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!-- 缓存,读取的时候不可以修改,留下使用最频繁的元素--> <cacheModel type="LRU" id="getAreas-cache"> <flushInterval hours="24"/> <property name="cache-size" value="1000"/> </cacheModel> <!-- 查询版块列表 --> <select id="getAreas" resultMap="area" cacheModel="getAreas-cache"> SELECT * FROM area </select> LRL代码当缓存满了时,去掉使用最不频繁的元素。 <cacheModel id="product-cache" type="FIFO"> <flushInterval hours="24"/> <flushOnExecute statement="insertProduct"/> <flushOnExecute statement="updateProduct"/> <flushOnExecute statement="deleteProduct"/> <property name=”size” value=”1000” /> </cacheModel> FIFO是当内存满了时,去掉旧的元素。 <cacheModel id="product-cache" type ="LRU" readOnly=”true”> <flushInterval hours="24"/> <flushOnExecute statement="insertProduct"/> <flushOnExecute statement="updateProduct"/> <flushOnExecute statement="deleteProduct"/> <property name=”cache-size” value=”1000” /> </cacheModel> flushOnExecute但调用某个方法是刷新缓存。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值