mybatis查询缓存——(十三)

时间:2023-03-09 01:02:32
mybatis查询缓存——(十三)

1.     mybatis缓存介绍

如下图,是mybatis一级缓存和二级缓存的区别图解:

mybatis提供查询缓存,用于减轻数据压力,提高数据库性能。

mybaits提供一级缓存,和二级缓存。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAo8AAAEACAIAAABd/Au8AAAPy0lEQVR4nO3c0WHaSBSGUUpwKX6mINfhEqiGZiiGPDgYIY0Ao2H0D5zzsgmWRsPmLp/A3myOAEC2zdobAABuUGsASKfWAJBOrQEgnVoDQDq1BoB0ag0A6dQaANKpNQCkU2sASKfWAJBOrQEgnVoDQDq1BoB0ag0A6Z5S68/Pzw1MfH5+PmPejBxXPG/qjCL3Wz6HT6n1ZuMtOwXPGwwjx5zGs2EUKVo+GGpNO2pNe2pNArWmJ2pNe2pNArWmJ2pNe2pNArWmJ2pNe2pNArWmJ2pNe2pNArWmJ2pNe2pNArWmJ2pNe2pNArWmJ2pNe2pNArWmJ2pNe2pNArWmJ2pNe2pNgneo9WG33Xzt663Hevqptal7HT3X2hy+jjer9f7r9Bekb3eH5Svvvx5f6GcrVbbxRrqsddDUjZapua0X9iK1zpnDyjt5F+9U68Nuu/m9zdx/rTcn/zdy2G2vDuv393fDTfWhv1rHTN2l/ddgU3MvmibwxyvUOmgOz1dfeOP5bvPZca0Pu+3pBu00hOeHvvb7r9McDOe1OBqDdxmDz4ym608eGX7KNPjieZXDbrvdHX7Xv/xESq3/bvVadz91BfuvmYNM4I/AWr/IHM6O3l3ebT6Xz+FKtS58O2Ywjz/DM5rX/4/OnzWcnen6M1c8r1x4rzK84sUx4yufDOfv3WbxHivX+gWmrvykznNoAqfiav0ic3jHcE6883x2XevLP+jLeRoN7+8XTnd6pxGdnjU3XYXRGt63ju5Lf9a/+MK4zpNaf39/v/Ms3iOg1p1P3cTw7Y0JLIqsdc9z+Pt++48fg7/5fHZb6+P505f/f+KXH6rMzevg1O3ucPE5UOGDnNFEjR85rTz+POf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Hw8Y96MHFc8b+qMIvdbPoduAwEgnVoDQDq1BoB0ag0A6dQaANKpNQCkU2sASKfWAJBOrQEgnVoDQDq1BoB0ag0A6dQaANKpNQCkU2sASKfWAJBOrQEgnVoDQLp//d28+YtgnAUAAAAASUVORK5CYII=" alt="" />

一级缓存是SqlSession级别的缓存。在操作数据库时需要构造 sqlSession对象,在对象中有一个数据结构(HashMap)用于存储缓存数据。不同的sqlSession之间的缓存数据区域(HashMap)是互相不影响的。

二级缓存是mapper级别的缓存,多个SqlSession去操作同一个Mapper的sql语句,多个SqlSession可以共用二级缓存,二级缓存是跨SqlSession的。

为什么要用缓存?

如果缓存中有数据就不用从数据库中获取,大大提高系统性能。

2.     一级缓存

  2.1     一级缓存工作原理

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAi8AAAFSCAIAAAC14qiRAAAd0ElEQVR4nO3dIXTqPBjG8cpJ5CRyErmDQl6JnERxJifnwE0ONzmJnOOTSCQSgUBOIif7CbZS2jR9m7RN2vx/4p5R2jR9F/LQ0juiGAAA1yLXHQAAgDQCAHiANAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuCdNo9FoFAEAUN1oNKotjaKIsygAgAlJgpBGAIBmkUYAAPdIIwCAe6QRAMA90ggA4B5pBABwjzQCALhHGgEA3CONAADukUYAAPdIIwCAe6QRAMA90ggA4B5pBABwjzQCALhHGgGtOa7G0XzjuheAl0gjwM5m/vfdlePVUb9qKo0qbCXtRC0NAa6QRoCF42ocJac7m3lJIPylUbWtWrVcLl13AYEijQALx9VYeU5yXI1/T33mm838b5V0Gikj6HrGlL6id23sb2luSfoaYOrJayvH1Xi8OibtF14vJI3gCmkE2LhM/ZnJPZU2l+czaVS6VbyZ3yTP7ZqKj59uW76edkW3/bhGV7qBdAKRRnCFNAJs/Z1x/EXJbVpkoil5onwrdXaoltycdWXOqi7t3zyRzr3lckkawQekEVCP42r8Gy2pE5u4OI1UW926SY/bGx6yS/5av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8fH09PTYDB4eHggjRAHU6hw06iurczazCSfMOdK91XLIWj6bN++Jj8y7ZeGruYdQJua2/Vut9N/qtR1/swYngukUKQRYIXBZozSCQVSKNIIsMJgM0bphAIpFGkEWGGwGaN0QoEUijQCrDDYjFE6oUAKRRoBVhhsxiidUCCFIo0AKww2Y5ROKJBCkUaAFQabMUonFEihSCPACoPNGKUTCqRQpBFghcFmjNIJBVIo0giwwmAzRumEAikUaQRYYbAZo3RCgRSKNAKsMNiMUTqhQApFGgFWGGzGKJ1QIIUijQArDDZjlE4okEKRRoAVBpsxSicUSKH6mUaDwSACWjEYDFyP967idSoUyBiLeplGAIBuIY0AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgHmkEAHCPNAIAuEcaAQDcI40AAO6RRgAA90gjAIB7pBEAwD3SCADgXp1pNBgMIgAAqhsMBrWlEQAAzSGNAADukUYAAPdIIwCAe6QRAMA90ggA4B5pBABwjzQCALhHGgEA3CONAADukUYAAPf+B+n9bdsoDjc8AAAAAElFTkSuQmCC" alt="" />

 缓存原理: 对sql语句进行计算后得出一个key值,根据此key查询缓存中是否有与此key相同的数据,如果没有查到就从数据库查询(会发出SQL语句查询)并将结果一级写入缓存。如果根据key值查到就直接返回结果。缓存就是一个hashmap。LocalCache是一级缓存的区域(HashMap).

第一次发起查询用户id为1的用户信息,先去找缓存中是否有id为1的用户信息,如果没有,从数据库查询用户信息。得到用户信息,将用户信息存储到一级缓存中。

如果sqlSession去执行commit操作(执行插入、更新、删除),清空SqlSession中的一级缓存,这样做的目的为了让缓存中存储的是最新的信息,避免脏读。

第二次发起查询用户id为1的用户信息,先去找缓存中是否有id为1的用户信息,缓存中有,直接从缓存中获取用户信息。

  2.2    一级缓存测试(根据日志信息是否发出SQL语句查询即可判断是否进行读数据库)

mybatis默认支持一级缓存,不需要在配置文件去配置。

按照上边一级缓存原理步骤去测试。

@Test

   public void testCache1() throws Exception{

      SqlSession sqlSession = sqlSessionFactory.openSession();//创建代理对象

      UserMapper userMapper = sqlSession.getMapper(UserMapper.class);

      //下边查询使用一个SqlSession

      //第一次发起请求,查询id为1的用户

      User user1 = userMapper.findUserById(1);

      System.out.println(user1);

//    如果sqlSession去执行commit操作(执行插入、更新、删除),清空SqlSession中的一级缓存,这样做的目的为了让缓存中存储的是最新的信息,避免脏读。

      //更新user1的信息

      user1.setUsername("测试用户22");

      userMapper.updateUser(user1);

      //执行commit操作去清空缓存

      sqlSession.commit();

      //第二次发起请求,查询id为1的用户

      User user2 = userMapper.findUserById(1);

      System.out.println(user2);

      sqlSession.close();

   }

  2.3    一级缓存应用

正式开发,是将mybatis和spring进行整合开发,事务控制在service中。

一个service方法中包括 很多mapper方法调用。

service{

//开始执行时,开启事务,创建SqlSession对象

//第一次调用mapper的方法findUserById(1)

//第二次调用mapper的方法findUserById(1),从一级缓存中取数据

//方法结束,sqlSession关闭

}

如果是执行两次service调用查询相同 的用户信息,不走一级缓存,因为service方法结束,sqlSession就关闭,一级缓存就清空。

3.     二级缓存

  3.1 原理

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnQAAAFuCAIAAACHrhL4AAAeWklEQVR4nO3dL3DbTLTGYcMPBn6w8IOGHqPAwMDCIk9gYVjMCmNWWBgY5sLCwsIAg8CyG3BBZi7RBUlk/VntHklH8ivr90ym08ry6tR7sq8ku+kiAwAArh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FdAWVMo+vx0i1wwAvM/unzvNAVnZPB6NsejNH5yYDwhiBcf/CNQR7gCykYKVwC+CFdAGeEKTBLhCgCAM8IVAABnhCsAAM4IVwAAnBGuAAA4I1wBAHBGuAIA4IxwBQDAGeEKAIAzwhUAAGeEKwAAzghXAACcEa4AADgjXAEAcEa4AgDgjHAFAMAZ4QoAgDPCFQAAZ4QrAADOCFcAAJwRrgAAOCNcAQBwRrgCAOCMcAUAwBnhCgCAM8IVAABnhCsAAM4IVwAAnM0oXC8uLhYAAAzv4uLCPcVyC6lwBQDgDBCuAAA4I1wBAHBGuAIA4IxwBQDAGeEKAIAzwhUAAGeEKwAAzghXAACcEa4AADgjXAEAcEa4AgDgjHAFAMAZ4QoAgDPCFQAAZ93Dlf97FQCAoPh/Fsu1KQAAzghXAACcEa4AADgjXAEAcLb4n//9P7744osvvvjiy/GLcOWLL7744osv56//B3ceWDuWr0gBAAAAAElFTkSuQmCC" alt="" />

原理:

  首先从缓存中查找,没找到就进行数据库查询,查询出的结果写入二级缓存,并计算命中率,第一次没找到命中率为0;第二次通过先从缓存中查找,找到之后命中率为0.5.

首先开启mybatis的二级缓存。

sqlSession1去查询用户id为1的用户信息,查询到用户信息会将查询数据存储到二级缓存中。

如果SqlSession3去执行相同 mapper下sql,执行commit提交,清空该 mapper下的二级缓存区域的数据。

sqlSession2去查询用户id为1的用户信息,去缓存中找是否存在数据,如果存在直接从缓存中取出数据。

二级缓存与一级缓存区别,二级缓存的范围更大,多个sqlSession可以共享一个UserMapper的二级缓存区域。

UserMapper有一个二级缓存区域(按namespace分) ,其它mapper也有自己的二级缓存区域(按namespace分)。

每一个namespace的mapper都有一个二缓存区域,两个mapper的namespace如果相同,这两个mapper执行sql查询到数据将存在相同 的二级缓存区域中。

  3.2     开启二级缓存

mybaits的二级缓存是mapper范围级别,除了在SqlMapConfig.xml设置二级缓存的总开关,还要在具体的mapper.xml中开启二级缓存。

1. 在核心配置文件SqlMapConfig.xml中加入

<setting name="cacheEnabled" value="true"/>

 

描述

允许值

默认值

cacheEnabled

对在此配置文件下的所有cache 进行全局性开/关设置。

true false

true

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhsAAACZCAIAAAAJom8QAAAgAElEQVR4nO2dTZqDIAyGe632QJ7DG9gdp2Drnh5CFh6BQzAL5CeQoLZqHZv36WLGWgxB80FAvdkPeD7s7WafI9jY3GyP7vkA/8Z9evt4IvunxTaPuB0tp2+QQirlg0P09gZtHp/5T6jygZ29vTVpKfZxA9YyDMNcm9unBcC4WcZix/Nhm8bebtMn7NPc4sbbzTYhrrtii+1UOdbLW/j09fLtJCTpzuX+6Vdo+ejGUE6mtQzDMNfmY0WBNEQYzcYcb7NVOQzDMMzmbKwoKLEj/1kKaKtyGIZhmD04QlEYhmGYX4AVhWEYhtmGf64oRt3bttEzO42G/G409HfWWmt7KculawAtb21b+whFTf2MStxa0dVM8MZr6coZtR6ttVY3bXtXM8Yvw3QisVbqUYnU/tS9s+5y3phrkeS4ctGugV62txa2iJapH0YlGxntR1z0QXsxDFPnfytKL9u70p2qRyUYMYtPDH9G3ZFvdVP5iU0jmm6mYGQ6MUW9UQki7kNJMOpOSEsv27sy/ij+V1qujcVLgQG6/HYmHEttre31ZFuiQKbXWbGmE0WVsSYoPK97WPXJRe6I0eFY+fbt9mIYZp7/rCghqs6E1xgvFn41KtFo00m0r1r8ZHWEigo3aUO9g2zUXWp3lDBg6mV9ZLOCXlYVYvpgDnSGwfoGLcEKz2wmIj5kVGJ+xKNVKCfZnxWFYY7m3yqKUfc0+PqkELprdYwCYmWW8CHiIPUT2U9dbNGZMLIpg5oJg6pRiUwLoVQQlktVbH9TYCYD/Mig0VPA9ZWSvdH9O8OIWP70r1F3IRuqIWDb1URuJiWVqgiuKOvbi2GYpeyiKL1cnR9fh1H3stdMzqlUxigFUzyVnXFjlNCNJUqbC69QtIBCpPm0IreWD4PSnJLV8i7dbMoOfep61ssmQxNkjILIbaIopSfJRF9oRzBGyW1LnOYKh6PVRJm8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R+VQ72fwN2pd+r3juB2nuf9CgzDMGflfUWpRNjak+nO/d4Rys6JkzxsjmEY5pS8oyhzLxhAZ1D+y3tHMDuLo1SrzzAM86N8NEZZ8iBxhP/y3pFoJyiQxygMwzAoH82jYIkvfInXf3nvCGWntZzyYhiGmeHjtV4wzlIDlP/y3hHCmDO9X4FhGOasbHs/yn94P0EBv3eEYRhmE65892Ydfu8IwzDMtvyuojAMwzDbworCMAzDbAMrCsMwDLMNrCgMwzDMNrCiMAzDMNvwB5Ek1YRJCn7EAAAAAElFTkSuQmCC" alt="" />

2. UserMapper.xml中开启二缓存

在UserMapper.xml中开启二缓存,UserMapper.xml下的sql执行完成会存储到它的缓存区域(HashMap)。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjEAAABUCAIAAAD8q/FjAAAPb0lEQVR4nO2dTW/bxhaG2R/QdZd373VWWlzdH+FdUHgj6B9koUVAooBXBQwvqjoLe1VACKyki7pVYQStLg01SZO4vWliuYhQSw4SQxBTI3UdOTGSzl3wa2Y4MxzSlDRK3gcHAcXhx5kjct6ZMyPHIiyP/3eXAAAAALPA4j5DkwAAAMwKaBIAAABTgCYBAAAwBWgSAAAAU7C++/F+50F39OKv12/OCTTpQ6VdJQsW2egR0iILFqm1Jnu7/ipZsMji6mTvYgotsmCRdtFX/bBiCLSZ8rtcONbJ+bvnxycPnzzd3eufvTmHJn2YbJTIQon0w5ZuozfZ20nb0x5ZnNpbNK17tatkoZrrTKWH0CSfGhei1gQf4JoVvCY+G6VpvCxZmfK7XDiWd/ZudPbWO3t7f//w6fBPqSZ5OyXn5rwpLtBloxS0bu0q89ZNm8kMKWZ7ryi2mZlmNOaUHllkm93+6sQe4BZZsKhvhPtoDOJ32dspOWur3gz90sUanJz79vj5y+87j8Sa1L1pOU5pZx4qBHIRdTbzN6BFMMEGZXb34jvy2kwzGvNKQrbzj0rT6K+ShSqphbfbqJJ+y8QvSPYut246luNUu7PySxfr8y+bvv38/NVX395JalJvZ42viedW7Gb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SIGiXI9Ghwh/nH0CslognsjnxkCgBwwCBTAIAEIFMAgAQgUwCABCBTAIAEIFMAgAQgUwCABCBTAIAEIFMAgAQgUwCABCBTAIAEIFMAgAQgUwCABCBTAIAEIFMAgAT8HzUmYncsXkz0AAAAAElFTkSuQmCC" alt="" />

为了将缓存数据取出执行反序列化操作,因为二级缓存数据存储介质多种多样,不一定在内存。

4.     测试方法(根据日志信息是否发出SQL语句查询即可判断是否进行读数据库)

// 二级缓存测试
@Test
public void testCache2() throws Exception {
SqlSession sqlSession1 = sqlSessionFactory.openSession();
SqlSession sqlSession2 = sqlSessionFactory.openSession();
SqlSession sqlSession3 = sqlSessionFactory.openSession();
// 创建代理对象
UserMapper userMapper1 = sqlSession1.getMapper(UserMapper.class);
// 第一次发起请求,查询id为1的用户
User user1 = userMapper1.findUserById(1);
System.out.println(user1); //这里执行关闭操作,将sqlsession中的数据写到二级缓存区域
sqlSession1.close(); //使用sqlSession3执行commit()操作
UserMapper userMapper3 = sqlSession3.getMapper(UserMapper.class);
User user = userMapper3.findUserById(1);
user.setUsername("张明明");
userMapper3.updateUser(user);
//执行提交,清空UserMapper下边的二级缓存
sqlSession3.commit();
sqlSession3.close(); UserMapper userMapper2 = sqlSession2.getMapper(UserMapper.class);
// 第二次发起请求,查询id为1的用户
User user2 = userMapper2.findUserById(1);
System.out.println(user2); sqlSession2.close(); }

5.     useCache配置

在statement中设置useCache=false可以禁用当前select语句的二级缓存,即每次查询都会发出sql去查询,默认情况是true,即该sql使用二级缓存。

<select id="findOrderListResultMap" resultMap="ordersUserMap" useCache="false">

总结:针对每次查询都需要最新的数据sql,要设置成useCache=false,禁用二级缓存。

7.     刷新缓存(就是清空缓存)

在mapper的同一个namespace中,如果有其它insert、update、delete操作数据后需要刷新缓存,如果不执行刷新缓存会出现脏读。

设置statement配置中的flushCache="true" 属性,默认情况下为true即刷新缓存,如果改成false则不会刷新。使用缓存时如果手动修改数据库表中的查询数据会出现脏读。

如下:

<insert id="insertUser" parameterType="cn.itcast.mybatis.po.User" flushCache="true">

总结:一般下执行完commit操作都需要刷新缓存,flushCache=true表示刷新缓存,这样可以避免数据库脏读。

4.     mybatis整合ehcache(重点)

ehcache是一个分布式缓存框架。

4.1     分布缓存

我们系统为了提高系统并发,性能、一般对系统进行分布式部署(集群部署方式)

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkAAAAG5CAIAAADpjRwtAAAgAElEQVR4nO3dMYzi6N3HcXc3TW6pIhe3WkuTk9BFp6GJFukUrZNmaE5DdYN0xXLNhqmCtMUhRQpTBU1xoYgSd4eUIm7uQomUhmIKqhMl1YjSJSWl3+LZ9et5bGyD8WP88P3odJpljHl45u/n58fYxvABAKggo+wGAABwCAIMAFBJBBgAoJIIMABAJRFgAIBKIsAAAJVEgAEAKokAAwq0Xq/n87njOMOPOp2OnabT6QTLj8fj+Xy+Wq3KfivAySHAgOPYbDaz2Ww4HPb7fdu26/W6YRiWZb1586bX6wWB5LruPI3rusHy/X7/zZs3Ym2vXr2ybVusbTqdep5X9psGykSAAYdbrVaTyaTb7dbr9RcvXrRarULnTOH53M3NjWmar1696nQ64/F4uVwe/eWAE0eAAfvxPM9xnFar9eLFi3q9/vbt28lkUtYhvvV67bpuv9+/urr65JNPbNsej8fr9bqUxgCKEWBAJpvNZjKZtFot0zR7vd5sNttsNmU36pntdjufz/v9vmVZzWbTcRyOMUJvBBiQYjKZ3NzcvHjx4u3bt7PZrOzmZLJYLHq9nmmatm07jrPdbstuEXB8BBiw02QyefXq1du3b6fTadltOdB8Pu/1eq9evRqPx8QYNEOAATGC6NLj8yTP8/r9PjEGzRBgwDOz2Uyn6AoLYmwymZTdFuAICDDgg+12+6c//anVaukXXWGe5719+7bdbp/aSSjAvggwwPd9f71ev379+l//+lfZDVHkv//979XVFVePodIIMMBfLpevX78+ymi+XC5Ho5G4icZoNDpWQqzX6/F4HNyeY7FYHGWdb968qcp5lUAUAYZzt1qtXr9+nf+SqcVi8fnnn3/xxRfffffdu3fv3r179913333xxReff/55nhhbr9e///3vP/vss2+//fbdR41G49e//nX+cyM3m8319fV8Ps+5HqAUBBjO2mazubq6yv+hl+d5L1++/Pnnn3+J+Pnnn3/zm98cHJBffvnlP/7xj+hq//e//11eXuaf4R2rBwD1CDCctZubm6Nc47Xdbl++fPnDDz9Ek+aHH374/PPPDz55/Xe/+91f/vKX6Gr/85//fPHFF8c67Hl1dZV/PYBiBBjO13Q6vbm5OdbaVqvV119//emnn75+/fqbb7755ptvXr9+/emnn3799dd55jebzebdu3effPLJ69evb25uvv3229evX3/22WdffvnlUT4JE/r9/ng8PtbaADUIMJwv27aP/vHPZrMRN4x3HGc+nx/rVHVxn8PJZCJudX/0I37r9frVq1fHXSdQNAIMZ2q9XluWVXYrTsibN284mwPVQoDhTM1ms1arVXYrTkiv13Mcp+xWAHsgwHCmHMfp9Xplt+KEiCvMym4FsAcCDGfquGdwaIDzOFA5BBjOFOeOS451RQGgDAGG81Wv11erVdmtOAmbzcY0Tb5pBdVCgOF8jcfjfr9fditOwt///vc///nPZbcC2A8BhvO13W6PdQ/fSvM8r16v8+0qqBwCDGdtuVw2m80zP3R2fX3NPelRRQQYzt10Om2322W3ojScfIjqIsAA/8cff7y+vt7rGNpyuRyPx6dz+HG9Xk8mk71upbHdbrvd7l//+tfCGgUUiwADfN/3Z7PZXp+Hrdfrfr/faDRqtVqn03EcR/0JjSK0ut2uZVmWZXW73b3ab9v2jz/+WGgLgUIRYMAH4pst//a3v+31rM1m47pur9er1+sXFxe2bYuDcke8k29A3CZ4MBjYtm2apgityWSy7719f/zxx6urqyPezB4oBQEG/L/tdvv9999bljWZTA57+nw+F2fn27Zdq9VEpNm2PRgMhsOh67rzkHDweJ4X/tVsNhP3dmq1WiKuDMOwbbvX641Go/l8ftg3ZE6n06urq263yzmH0AABBsjW67U4LndYjIWJSJvP56PRaDgcdjodO8SyLOMj0zTDv2q1WiLAZrPZwXEVJqLr5ubmdD63A3IiwIB4IsZevnz5z3/+s7rzle12++9///u3v/0t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p/ikeAcxecvnfzqqQHmPz9cFk2UXT+HnyXWE5x6F8zA/I/ZYzw/CzF43SA2om3wQ4cWxfROCrAs4134UF5wEkc0wGLbGbyX2I7yd8/Awl1hPD+JI7bZGd+L9uiEItCnSFHuhne2m/3ZvnFd8QctAn2KFGx4QH5sR0WgT5GCDQ/Ij+2oCPQpUrDhAfmxHRWBPkUKNjwgP7ajItCnSMGGB+THdlQE+hQp2PCA/NiOikCfIgUbHpAf21ER6FOkYMMD8mM7KgJ9ihRseEB+bEdFoE+Rgg0PyI/tqAj0KVKw4QH5sR0VgT5FilqtZgDIp1arlb0pa4gAAwBUEgEGAKgkAgwAUEkEGACgkggwAEAlEWAAgEoiwAAAlUSAAQAqiQADAFQSAQYAqCQCDABQSQQYAKCSCDAAQCURYACASiLAAACVRIABACqJAAMAVBIBBgCopP8D7ercyi0w7I4AAAAASUVORK5CYII=" alt="" />

不使用分布缓存,缓存的数据在各各服务单独存储,不方便系统 开发。所以要使用分布式缓存对缓存数据进行集中管理。

mybatis无法实现分布式缓存,需要和其它分布式缓存框架进行整合。

4.2     整合方法(掌握)

mybatis提供了一个cache接口,如果要实现自己的缓存逻辑,实现cache接口开发即可。

mybatis和ehcache整合,mybatis和ehcache整合包中提供了一个cache接口的实现类。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAApcAAAGfCAIAAACFtW42AAAgAElEQVR4nO3dPYvrSALucX+uTvwpTuzE+BNMajpS3hM0OOtgwUkH06wXbyi8GPZiaOhlrzrpYOWFaRYf9nJgzL4luoEkq6pUVSq9WuX+/zDMHMuSSrJbj+tFrkmSJP/37f8kAADAN5OEFAcAwE+kOAAAviLFAQDwFSkOAICvSHEAAHxFigMA4CtSHAAAX5HiAAD4ihSHq+1iMlls+9jyx8PdZDKZTO4ePvrYPADcrE5S/Nfd3bf7yU873SX4+8NP95Nv2ePul+/lV2x/Ni5qpskGD8+Tb/eLQ1dFSJIkPy3Z47mX+KuU5+NkMmkdwX2l+HZBfgNAM9d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BrnB0BOrYAAAAASUVORK5CYII=" alt="" />

mybatis默认实现cache类是:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnMAAAD9CAIAAABY92bYAAAaRElEQVR4nO3dPXLzsHqGYayL+9AOznAFbjPaAlRoC2lUuMgM29jdGVUpYjds3LixZ9LkuEnDFPzDP0HppUhJ9zUqPokESFoEHwHgJ6n/+d//ax///V//bK7yr3//t//8x3/867pKAAC4b0ouWQEAAMkKAIAokhUAAEkkKwAAkkhWAAAkkawAAEgiWSGnKlWvrJbf1NLbwE0s91bWulBKKVXoeonqgSjBZP1+L3Z79fIeOol/9cte7bpH8frrr1EdoovkTO/GTRgBdJMUmtgV8c3HKu0vdBIHvdTlWO483MjJ1jRN05xParcvz3IV3sVbWZKpWMtWkrVb4XmSdbyUVOWKn6pvl6xVaV+Dq/Kq7S50ORY8DzdysjVN/3FBLFnv462sdUGwYi03StZO/Xpc/Sqzgd1wLyUrfri+VbKKH+LdjAavfbI1jXCy3stbSbJiRcFkbTPy8Nk2SGXmpROf55Pa7dXh01xUvR7dUr3QVWbqo327ie5x1N95x5UsNbkb40F1Pktz0e5UZS2KCSWr1QUID7RVpSp0bSweFrZLorOcoQqt4bzecCEK7JG7w16Z+PFNX41TFVp76uzhuMwpFfsbxsXOw1/9sleHU/cuH9671dpzO9FSht0PJ2twc8ltJXYyuhveWb1zInb+2XsHb+W4MZIVK0kkq/Ow4zOarMFSvbnJWg8hPSdZJ0tlJeu4gnP1MS9AiUUJgdFgK/CGZfaz7hLTXS3MZd2S7plVKlWhtyuxl62ntS4iOx+t1NusJVVhsH7/kK3L/cQhRyST1T+x25NK4pw3tpjcVuIUDe1GosI+WS85e+/hrRyrvYtRDTyiZLJ2LbB7eqqarGQNlOolRsZCi7qWP3MUa7rU9ACdeVzDBci+Yk4tSnDuYDKav/c527w8OL0FY914JzhZYaDkrLVii2Yma7xwotsR38OpQ07zzo02nI76exxTbdcpz5ee8+3Z5TSil/c6va1oqXE3uq1YZ2/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MpNLQMjUBHABYNdAQaAR2BRkBHoBH/AXsf6HSVMT38AAAAAElFTkSuQmCC" alt="" />

4.4     整合ehcache

配置mapper中cache中的type为ehcache对cache接口的实现类型。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAh4AAACQCAIAAADIhPWcAAAbYElEQVR4nO2dPW/cuBaG9XtcL1y48f0FqdIuDAOGa7cuDA0WMODu2sgOki1SBfAGGAcpkkyRLeZOYGCDYLOu7BQu7DSB4emC1OEt9MWvc0hpKIkavw8IQxYl6pCizssPaZgIAAAAIChJ3wYAAABYNSAtAAAAAgNpAQAAEBhICwAAgMBAWgAAAAQG0gIAACAwkJYHx2xXrCXi+bUQU7GWiP1pu5e7ORZriXh83O5VYmEq1hIxC53qwypD4E3Hz3ItIC0PjucbYm1D3BQO6/l1u5cj3eK1eNzZw9DVtWa7Ym230ZmshZCWjH2tiKYtVuD9JH9MMp5vdPGw1KXjZ7kWNmlZfNgYvYpJ/0BInm/kTmq2qzw8XdNOA7/fa5VlW5suS2OgXIvHqve8OW6tAk/FWiLdEe3faLA/y4sPG6Onx4se7RLCIi1Xr5LRaOND33aB1iibfs39YAha9Av9XUtvVnvTZWkMFUN9m/cRXdwci7VdsV9c7vmuuJnGeIOoZ3n6apSMRrtXfdklhCYt1x+e6gYt5jvp5HQ+3kzTzfH869VkM00308l5eUC+J80PKHafT9Kd+eJ8UkRJpzBReoKTK2X/eP5VXB0WsYceBXe1m46PF1e7aZpkYaKcNJ0U+9N0Y57L6fV8nEzmx+N8Z36MdKJ8lnr3FtlZxrWamFHegI3yrHQsN0VoM5pTtM7MJtssGyJIaozMZGMI5hBwuV8O5kCHbobtXPmsfTnBXe9rEZbvT/Nzy40s19nIg2xSJSdFs7q8qFZQVuN5C6kyZLLcLF+MhVm+ZsKWLyZKCFFMBphRWaFlhenZITA72Zo/ZUqjrhllQWXTGPkxUpoxF1R+wQ9P++0kVNIyfTVKzG7UYr6TaUa5Ia4OS7e+mO9I/vNQEoNcOfJ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yMt0RTv3fef7neO4+615ME61/L2T3MSJc/zH0+UKFkz6LMc0nLwuZHxTMfibJKuz798v3whdVnuuF7L5QtthqYKjQbEDOcr9z/IvojqlLNmjnOipXrUz6QN6er/HFm6MndG36J6flxm8APW5uyO9QAfB+0c07dayLyxs2eb8TITdJS296gRdRhpRpRZ1oL/HH50+XJJSwzFe/fd9SZYzbeuIntD7Ga+pU3d50GdC8mm38t/ybMYadHmWuoEc8ZesvPdevpie6LNxqvScvkiqQbB1LkWr+DstZR1TvNH/GOWnaWN4coHWERrW9kotSQPWSfJuvNCSkSdCqrMWNcfEl48KuG5EHu2bFpOt+XrzjU6T1lInkVPO915z6b4G08myJoRUZZXMV/ZrKTc6vKp863WKDOcviR7JEN6QywP5nctN/Ot1PaGmLz/yfzt+7EyCEacxUjLXa4ulhE2Z5BfFVNmSoooTXikd8NSM1Z/8cz1kphjGl9+n8SYqOA/NsxOeW12Doo0tVdrtFcYrdM8elLaZKwaK5vxj639tcd088+MNI2JX+oU8+lV3tiRjOQttJ6ldbasE0jUKEoT44kTHWbEkGUmX8YpZXtlKPmSE5Qfk66Llwz0BP7wvmtZxfDlaCy/J5YFfUBsudD2b4hp84rNQ71XUxAQEHoLH/966jM57x8gLUEDMVYWubQoo9ih9ID8eSIEBITYQoAfDdMCpCVMKAe1rHMwkUvLnfqB1ZK6Unbhh/hzLAgICEECpGV4AatMIiAgRB6SjhdMBgAAsPJAWgAAAAQG0gIAACAwkBYAAACBgbQAAAAIDKQFAABAYCAtAAAAAgNpAQAAEJj/A+qjnrOvPp1LAAAAAElFTkSuQmCC" alt="" />

4.5    加入ehcache的配置文件

ehcache.xml

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../config/ehcache.xsd">
<diskStore path="F:\develop\ehcache" />
<defaultCache
maxElementsInMemory=""
maxElementsOnDisk=""
eternal="false"
overflowToDisk="false"
timeToIdleSeconds=""
timeToLiveSeconds=""
diskExpiryThreadIntervalSeconds=""
memoryStoreEvictionPolicy="LRU">
</defaultCache>
</ehcache>

5.     二级应用场景

对于访问多的查询请求且用户对查询结果实时性要求不高,此时可采用mybatis二级缓存技术降低数据库访问量,提高访问速度,业务场景比如:耗时较高的统计分析sql、电话账单查询sql等。

实现方法如下:通过设置刷新间隔时间,由mybatis每隔一段时间自动清空缓存,根据数据变化频率设置缓存刷新间隔flushInterval,比如设置为30分钟、60分钟、24小时等,根据需求而定。

6     二级缓存局限性

mybatis二级缓存对细粒度的数据级别的缓存实现不好,比如如下需求:对商品信息进行缓存,由于商品信息查询访问量大,但是要求用户每次都能查询最新的商品信息,此时如果使用mybatis的二级缓存就无法实现当一个商品变化时只刷新该商品的缓存信息而不刷新其它商品的信息,因为mybaits的二级缓存区域以mapper为单位划分,当一个商品信息变化会将所有商品信息的缓存数据全部清空。解决此类问题需要在业务层根据需求对数据有针对性缓存。