Mabatis 一、二级缓存
一、一级缓存
1.核心特征
1-1 缓存级别
一级缓存为SqlSession级别的缓存,默认是开启状态的
1-2作用域
只作用于单个SqlSession
1-3 生命周期
随SqlSession创建而创建,随SqlSession关闭或清空而销毁
1-4存储位置
内存中的HashMap中存储(非序列化)
2. 工作流程
3. 缓存失效场景
3-1 执行写操作 (增,删,改)
3-2 手动清理缓存(调用sqlSession.clearCache())
3-3 查询条件发生变化:
select from table where id = ? ====> select from table where name = ?