In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Mybatis how to achieve a level of cache and secondary cache, in response to this problem, this article describes the corresponding analysis and solution in detail, hoping to help more small partners who want to solve this problem find a simpler and easier way.
Level 1 cache
The first level cache is a SqlSession level cache. When operating the database, you need to construct sqlSession object, in which there is a data structure (HashMap) for storing cached data. The cache data area (HashMap) between different sqlSessions is independent of each other.
The same query statement (with the same parameters) under the same SqlSession returns results from the cache; update statements (update, insert, delete) flush the cache.
II. Level 2 cache
The second level cache is based on the namespace of the mapper file, that is to say, multiple sqlSessions can share the second level cache area in a mapper, and if the namespaces of two Mappers are the same, even if it is two Mappers, then the data obtained by executing sql queries in the two Mappers will also exist in the same second level cache area.
Second level cache is based on namespace. If a user table has two Mappers with different namespaces querying and changing it, they are invisible to each other and easy to read expired data.
About Mybatis how to achieve the first level cache and the second level cache questions to share here, I hope the above content can be of some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.