---
title: "ibatis缓存"
author: "hyh2011"
date: "2011-05-27T17:25:13Z"
tags: []
categories: ["编程语言"]
slug: "ibatis"
draft: false
lastmod: "2011-05-27T17:25:13Z"
id: 1062042
url: "https://hyh2011.iteye.com/blog/1062042"
---

iBATIS缓存的使用方法－－摘自iBATIS官方文档 收藏 iBATIS可以在Mapped Statement中使用缓存模型，在内存中缓存常用的数据。属性 cacheModel 定义查询 mapped statement 的缓存。每一个查询 mapped statement 可以使用不同或相同的cacheModel。以下给出个例子： &lt;cachemodel id="product-cache" imlementation="LRU"&gt;&lt;flushinterval hours="24"&gt;&lt;/flushinterval&gt;&lt;flushonexecute statement="insertProduct"&gt;&lt;/flushonexecute&gt;&lt;flushonexecute statement="updateProduct"&gt;&lt;/flushonexecute&gt;&lt;flushonexecute statement="deleteProduct"&gt;&lt;/flushonexecute&gt;&lt;property name="size" value="1000"&gt;&lt;/property&gt;&lt;/cachemodel&gt;&lt;statement id="getProductList" parameterclass="int" cachemodel="product-cache"&gt; select * from PRODUCT where PRD\_CAT\_ID = #value# &lt;/statement&gt;