mybatis_03:缓存

local cache

http://www.mybatis.org/mybatis-3/java-api.html

Mybatis uses two caches: a local cache and a second level cache

local cache

each time a new session is created
Mybatis creates a local cache and attaches it to the session.

所以同一session内的相同请求会走缓存。

当执行 update, commit, rollback,and close,the local cache 会被清除,

当设置全局localCacheScope=STATEMENT,彻底的没有缓存了。

默认 localCacheScope=SESSION,表示可以在单个session内走缓存。

全局settings

localCacheScope:
local cache

mybatis_03:缓存
local cache .png

SESSION: 作用域在session级别

STATEMENT: 作用域在 preparedStatement级别

a second level cache
不要开启mybatis的二级缓存,
避免脏数据。

ORM: Object Relational Mapper