mybatis缓存

来源:互联网 发布:手机注销淘宝账号 后果 编辑:程序博客网 时间:2024/06/04 23:27
当使用同一个sqlSession条用相同的sql语句时,mybatis默认使用缓存中的sql语句;
默认select使用缓存,insert delete update不使用缓存

<!--
1,size:表示缓存cache中能容纳的最大元素数。默认是1024;
2,flushInterval:定义缓存刷新周期,以毫秒计;
3,eviction:定义缓存的移除机制;默认是LRU(least recently userd,最近最少使用),还有FIFO(first in first out,先进先出)
4,readOnly:默认值是false,假如是true的话,缓存只能读。
-->
<cache size="1024" flushInterval="60000" eviction="LRU" readOnly="false"/>

此配置必须放在<mapper namespace="com.czp.mappers.StudentMapper"> 下方
原创粉丝点击