首页 > 系统服务 > 详细

cache

时间:2018-11-06 00:23:33      阅读:174      评论:0      收藏:0      [点我收藏+]

二级缓存

<mapper namespace="com.abc.dao.IStudentDao">
    
    <!-- 开启二级缓存 -->
    <cache size="512" eviction="LRU" flushInterval="100000"/>

    <insert id="insertStudent" flushCache="false">
        insert into student(name,age,score) values(#{name}, #{age}, #{score})
    </insert>
    
    <delete id="deleteById">
        delete from student where id=#{xxx}
    </delete>
    
    <update id="updateStudent">
        update student set name=#{name}, age=#{age}, score=#{score} where id=#{id}
    </update>
    
    <select id="selectStudentById" resultType="Student">
        select id,name,age,score from student where id=#{ooo}
    </select>
    
    <select id="selectStudentById2" resultType="Student">
        select id,name,age,score from student where id=#{ooo}
    </select>
    
</mapper>

 

 

<mapper namespace="com.abc.dao.IStudentDao">
    
    <!-- 开启二级缓存 -->
    <cache type="org.mybatis.caches.ehcache.EhcacheCache">
        <property name="maxElementsInMemory" value="1000"/>
        <property name="timeToLiveSeconds" value="240"/>
    </cache>

    <insert id="insertStudent" flushCache="false">
        insert into student(name,age,score) values(#{name}, #{age}, #{score})
    </insert>
    
    <delete id="deleteById">
        delete from student where id=#{xxx}
    </delete>
    
    <update id="updateStudent">
        update student set name=#{name}, age=#{age}, score=#{score} where id=#{id}
    </update>
    
    <select id="selectStudentById" resultType="Student" useCache="false">
        select id,name,age,score from student where id=#{ooo}
    </select>
    
    <select id="selectStudentById2" resultType="Student">
        select id,name,age,score from student where id=#{ooo}
    </select>
    
</mapper>

 

cache

原文:https://www.cnblogs.com/csslcww/p/9912403.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!