MyBatis of cache and a cache miss

 

definition:

Cache: Local cache: the same query during a session (sqlSession) and database data will be placed in the local cache, if they wanted to get the same data directly from the cache, the data will not query the database again
a SqlSession have a cache
myBatis always on a cache, SqlSession different level cache, the data can not be shared

A cache invalidation case :( do not use the current cache, and if not, the effect is the second time the same query needs to send sql database)
1.sqlSession different
2. When the same sqlSession objects when the query different conditions ,, because the first query cache when no data is required for the second query
3. sqlSession when the same object, the insertion operation between the two queries
same sqlSession 4. when the object manually Clear the data in the cache

 

Guess you like

Origin www.cnblogs.com/luyuan-chen/p/11628817.html