Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of caching in Mybatis

Shulou Source: shulou.com Published: 2022-06-01 03:30:05 09月22日 Update

This article mainly shows you the "sample Analysis of caching in Mybatis", which is easy to understand and well organized. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "sample Analysis of caching in Mybatis".

The primary and secondary caches of Mybatis.

1) first-level cache: PerpetualCache-based HashMap local cache, whose storage scope is Session. After Session flush or close, all Cache in the Session will be cleared, and first-level cache will be turned on by default.

2) the mechanism of the second-level cache is the same as that of the first-level cache, except that the storage scope is Mapper (Namespace) and the storage source can be customized, such as Ehcache. The second-level cache is not enabled by default. To enable the second-level cache, you need to implement the Serializable serialization interface (which can be used to save the state of the object) to use the secondary cache property class, which can be configured in its mapping file.

3) for the cache data update mechanism, when the C/U/D operation is performed in a certain scope (first-level cache Session/-second-level cache Namespaces), by default all caches in the select under that scope will be clear.

The above is all the content of the article "sample Analysis cached in Mybatis". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Cache function storage example analysis content article mechanism learning help different same available in object property sequence interface data file easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei NVidia Apple Shulou Technology