iBATIS CacheModel使用浅析
iBATIS CacheModel的使用是什么情况呢?让我们首先从现状入手,Cache也是经常讨论的一个话题之一,在我们系统开发的过程中,总会存在着这样一类数据,它们更新频率很低,然而使用的频率却非常之高。为了提高系统性能,我们通常将此类数据装入缓存。iBATIS.NET也有自己的缓存系统。
MappedStatement的查询结果集可以根据CacheModel的值来确定它是否被装入缓存以及如何装入缓存。而iBATIS CacheModel也是在配置文件中事先定义好的。具体的定义方式如下:
﹤cacheModel id="employee-cache" implementation="LRU" readOnly="true" serialize="false"﹥ ﹤flushInterval hours="24"/﹥ ﹤flushOnExecute statement="insertEmployee"/﹥ ﹤flushOnExecute statement="updateEmployee"/﹥ ﹤flushOnExecute statement="deleteEmployee"/﹥ ﹤property name="CacheSize" value="100"/﹥ ﹤/cacheModel﹥
﹤statement id="EmployeeList" cacheModel="employee-cache"﹥ select * from Employee ﹤/statement﹥