cache

Posted csslcww

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cache相关的知识,希望对你有一定的参考价值。

二级缓存

<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的主要内容,如果未能解决你的问题,请参考以下文章

如何使控制台中的视图缓存片段过期?

MODx片段:Tweet这个

phalcon: 缓存片段,文件缓存,memcache缓存

C# Cache的一些总结

在每个用户的Rails中使用片段缓存

如何在 Django 中显式重置模板片段缓存?