Open cache:
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Mapper Public "-//mybatis.org//dtd mapper 3.0//en" "Http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace= "Com.shop.mapper.ArticleListMapper" >
<cache eviction= "LRU" flushinterval= "60000" size= "1024" readonly= "false"/>
Description
The eviction is the cache elimination algorithm, the optional value has "LRU", "FIFO", "SOFT", "WEAK", the default value is LRU
Flashinterval refers to the cache expiration time in milliseconds, 60000 is 60 seconds, and the default is empty, that is, as long as the capacity is sufficient to never expire
Size refers to how many objects are cached, with a default value of 1024
ReadOnly is read-only, if true, all the same SQL statements return the same object (which can help improve performance but may not be secure when you manipulate the same data concurrently), and if set to False, the same SQL, followed by the cache clone copy.
Precautions:
This is the global setting, and you can have local settings on each individual SQL statement, such as:
<select id= "GetOrder" parametertype= "int" resulttype= "Torder" usecache= "false" >
...
</select>
Usecache= "False" indicates that the SELECT statement does not use caching (even if the XML's first global cache is enabled)
By default, if the cache is turned on globally, the associated cache entry is automatically refreshed when the Insert/update/delete succeeds, but one particular note: When MyBatis and hibernate are mixed, because MyBatis is not related to the hibernate cache , if you use MyBatis to do a select query, use Hibernate to do insert/update/delete,hibernate changes to the data, and does not refresh the MyBatis cache.