Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MyBatis Cache configuration

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

MyBatis provides first-level cache and second-level cache

Configure global configuration description default value cacheEnabled global cache switch truetrue falselocalCacheScope local cache, SESSION indicates that the executed sql result cache data can be shared in the same sqlSession

STATEMENT, on the other hand, is the same only if a single statement is cached

Two statements cannot share cache data SESSIONSESSION STATEMENT Mapper configuration flushCache=true represents the execution result of the statement, empties the local cache and level 2 cache useCache= "true" indicates the execution result of the statement, and is cached to the default value of level 2 cache: current Mapper cache configuration, secondary cache: cache is only used for a specific Namespace, that is, each namespace uses one cache instance, if multiple namespace use the same cache instance You can use cache-ref to refer to the cache configuration attribute to indicate the default value eviction reclaim memory policy LRULRU FIFO SOFT WEAKflushInterval refresh interval is not set greater than 0 (in ms) the number of size cache objects 1024 is greater than 0readOnly if true returns all callers to the same instance, although the performance is improved

But the program is required to ensure that the instance object is not modified, if it is false

Is read-write cache, and a Copy of the cached object is returned by serialization

Slower, but safer falsetrue falsetype can specify a custom cache, but this class must implement the

Org.apache.ibatis.cache.Cache interface

Com....class customizes the overall management structure of secondary cache:

MapperA.xml

MapperB.xml

MapperC.xml

As follows:

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.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report