MyBatis增删改对二级缓存的影响
生活随笔
收集整理的這篇文章主要介紹了
MyBatis增删改对二级缓存的影响
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*增刪改對二級緩存的影響*//*1、增刪改同樣也會清空二級緩存2、對于二級緩存的清空,實質是對所查key對應的value置為null,而并非key-value對,即Entry對象刪除3、從DB中進行select查詢的條件是:1)緩存中根本就不存在這個key2)緩存中存在該key所對應的的Entry對象,但其value為null*/@Testpublic void test01() {sqlSession = MyBatisUtils.getSqlSession();dao = sqlSession.getMapper(IStudentDao.class);Student stu = dao.selectStudentById(2);System.out.println(stu);sqlSession.close();sqlSession = MyBatisUtils.getSqlSession();dao = sqlSession.getMapper(IStudentDao.class);/*插入*/dao.insertStudent(new Student("hello",22,86));Student stu1 = dao.selectStudentById(2);System.out.println(stu1);}
?
總結
以上是生活随笔為你收集整理的MyBatis增删改对二级缓存的影响的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MyBatis从缓存查找数据的依据
- 下一篇: MyBatis二级缓存的配置