标签:
mybatis缓存分为1级缓存和2级缓存,2级缓存在sessionfactory中,1级缓存在session中。
session中的缓存在session连接关闭并被连接池回收时清理,或者手动清理
sessionfactory中的缓存需要在mybatis配置文件中手动配置,配置如下:
<setting name="cacheEnabled" value="true"/>
<mapper namespace="dao.userdao"> ... select statement ... <!-- Cache 配置 --> <cache eviction="FIFO" flushInterval="60000" size="512" readOnly="true" /> </mapper>
flushInterval:刷新轮询时间,每隔这个时间后缓存被清理一次。
参考博客园地址:http://www.cnblogs.com/zemliu/archive/2013/08/05/3239014.html
标签:
原文地址:http://my.oschina.net/u/1445731/blog/416200