mybatisplus 二级缓存

1将mybatisplus的全局配置的cache-enabled配置为true

mybatis-plus:
  dataSource: datasource
  mapper-locations: classpath:/mapper/*/*Mapper.xml
  typeAliasesPackage: com.wbst.modules.*.entity
  global-config:
    id-type: 2
    field-strategy: 2
    db-column-underline: true
    refresh-mapper: true
    configuration:
      map-underscore-to-camel-case: true
      cache-enabled: true

2在需要配置二级缓存的mapper映射文件如:test.xml加入如下配置:

<cache eviction="FIFO"
flushInterval="10800000"
size="512"
readOnly="true"
/>

这个最好写在开头位置,一般第一条查询语句前面的可以了
3有些select不想被缓存时,可以添加select的属性useCache=“false”
4将查询结果对应的java实体类实现序列化接口(implements Serializable)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值