美文网首页
ehcache 3.5.x 配置文件说明

ehcache 3.5.x 配置文件说明

作者: DaFengS | 来源:发表于2019-02-26 09:59 被阅读0次

环境版本:

ehcache版本3.5.2

SpringBoot版本2.0.4

JCache API版本1.1.0

<config

        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'

        xmlns='http://www.ehcache.org/v3'

        xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core.xsd">

    <!--persistence节点是配置持久化存储的磁盘路径,如果不做磁盘持久化配置,需要注释掉该节点,同时也注释掉cache.resources.disk节点-->

    <!--<persistence directory="/usr/local/apache-tomcat-8.5.31/webapps/ehcacheData"/>-->

    <!--缓存模版,此处为了显示其用法,也可以不用模版直接在cache中配置与模版参数相同-->

    <cache-template name="template">

        <!--缓存条目索引-->

        <key-type>java.lang.String</key-type>

        <!--缓存条目类型-->

        <value-type>java.lang.String</value-type>

        <!--缓存过期时长-->

        <expiry>

            <!--unit默认为秒-->

            <ttl unit="hours">1</ttl>

        </expiry>

        <!--配置各个存储位置-->

        <resources>

            <!--配置堆储存,unit默认为entries-->

            <heap unit="MB">200</heap>

            <!--配置堆外储存,堆外存储容量必须大于堆存储容量-->

            <offheap unit="MB">500</offheap>

            <!--配置磁盘持久化储存,persistent=是否启用磁盘缓存,默认为false-->

            <!--<disk unit="MB" persistent="false">500</disk>-->

        </resources>

    </cache-template>

    <!-- 缓存对象,如果使用了模版,与模板相同节点的配置参数会覆盖模版中的内容,使用uses-template="模板名称" 来引用模版 -->

    <cache alias="myCache" uses-template="template">

        <key-type>java.lang.String</key-type>

        <value-type>java.lang.Object</value-type>

        <expiry>

            <tti unit="minutes">5</tti>

        </expiry>

        <!--<resources>-->

            <!--<disk unit="MB" persistent="false">1</disk>-->

        <!--</resources>-->

    </cache>

</config>

相关文章

网友评论

      本文标题:ehcache 3.5.x 配置文件说明

      本文链接:https://www.haomeiwen.com/subject/vrboyqtx.html