ibatis中使用缓存
2008-01-25 11:31
344 查看
简单在ibatis中使用cache
首先设置SqlMapConfig.xml中<settings/>节点的属性cacheModelsEnabled="true"
然后在具体sqlmap文件中书写<cacheModel>
<cacheModel id="product-cache" type="LRU">
<flushInterval hours="24"/>
<flushOnExecute statement="insertProduct"/>
<flushOnExecute statement="updateProduct"/>
<flushOnExecute statement="deleteProduct"/>
<property name="size" value="1000" />
</cacheModel>
最后给<select/>节点应用cache
<select id="getAllProducts" cacheModel="product-cache">
select * from PRODUCT
</statement>
复杂点的用法
<cacheModel/>节点
type="LRU"
type属性可以指定cache的类型,ibatis支持3种缓存:
MEMORY 没有统一的对象重用模式或内存不足的应用。
LRU 经常使用的对象,这是性能最好的选择。
FIFO 在短时间内持续引用,而后很可能不再使用。
也可以使用外部cache如:
type="OSCACHE"
readOnly="true"
默认true时缓存效果最好,可以减少更新。
serialize="false"
默认false,设true可以提高整体应用的性能。
serialize只能应用于实现了Serializable接口的对象,而且和lazyLoadingEnabled="true"属性冲突。
flushInterval
自动刷新间隔时间。
flushOnExecute
在特定id的操作后,刷新cache,可选操作。
手动刷新缓存
[sqlmap].flushDataCache("product-cache")
刷新cache当id="product-cache"
[sqlmap].flushDataCache()
刷新sqlmap内的所有cache
首先设置SqlMapConfig.xml中<settings/>节点的属性cacheModelsEnabled="true"
然后在具体sqlmap文件中书写<cacheModel>
<cacheModel id="product-cache" type="LRU">
<flushInterval hours="24"/>
<flushOnExecute statement="insertProduct"/>
<flushOnExecute statement="updateProduct"/>
<flushOnExecute statement="deleteProduct"/>
<property name="size" value="1000" />
</cacheModel>
最后给<select/>节点应用cache
<select id="getAllProducts" cacheModel="product-cache">
select * from PRODUCT
</statement>
复杂点的用法
<cacheModel/>节点
type="LRU"
type属性可以指定cache的类型,ibatis支持3种缓存:
MEMORY 没有统一的对象重用模式或内存不足的应用。
LRU 经常使用的对象,这是性能最好的选择。
FIFO 在短时间内持续引用,而后很可能不再使用。
也可以使用外部cache如:
type="OSCACHE"
readOnly="true"
默认true时缓存效果最好,可以减少更新。
serialize="false"
默认false,设true可以提高整体应用的性能。
serialize只能应用于实现了Serializable接口的对象,而且和lazyLoadingEnabled="true"属性冲突。
flushInterval
自动刷新间隔时间。
flushOnExecute
在特定id的操作后,刷新cache,可选操作。
手动刷新缓存
[sqlmap].flushDataCache("product-cache")
刷新cache当id="product-cache"
[sqlmap].flushDataCache()
刷新sqlmap内的所有cache
相关文章推荐
- IBatis.Net使用MemCached替换内置缓存策略
- 详细分享IBatis.net缓存的使用方法
- 关于iBatis的缓存使用
- ibatis中使用缓存
- ibatis中使用缓存
- 关于iBatis的缓存使用
- ibatis 动态列缓存问题;oracle行转列;oracle使用数字或特殊字符作列的别名
- ibatis中使用缓存
- iBATIS缓存的使用方法--摘自iBATIS官方文档
- Ibatis的缓存(cache)的使用
- iBATIS缓存的使用方法--摘自iBATIS官方文档
- 补充关于iBatis的缓存使用
- iBatis缓存的使用方法及解释
- iBATIS缓存的使用方法
- 使用IBatis作数据缓存
- 关于iBatis的缓存使用
- ibatis中使用缓存
- 谨慎使用ibatis中的缓存 |
- iBatis缓存的使用方法及解释
- ibatis缓存的设置使用