變更緩存供應(yīng)商EHCACHE
變更緩存供應(yīng)商EHCACHE
導(dǎo)入相關(guān)坐標(biāo)依賴
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
導(dǎo)入相關(guān)配置
spring.cache.type=ehcache
導(dǎo)入ehcache xml配置
這里需要指定特定的緩存位置 testCache,timeToIdleSeconds 表示設(shè)置緩存的時間文章來源地址http://www.zghlxwxcb.cn/news/detail-601497.html
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<!--持久化磁盤路徑-->
<diskStore path="java.io.tmpdir"/>
<!--默認(rèn)緩存設(shè)置-->
<defaultCache maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="true"
maxElementsOnDisk="10000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="FIFO"
/>
<!--
<cache name 緩存名唯一標(biāo)識
maxElementsInMemory="1000" 內(nèi)存中最大緩存對象數(shù)
eternal="false" 是否永久緩存
timeToIdleSeconds="3600" 緩存清除時間 默認(rèn)是0 即永不過期
timeToLiveSeconds="0" 緩存存活時間 默認(rèn)是0 即永不過期
overflowToDisk="true" 緩存對象達(dá)到最大數(shù)后,將其寫入硬盤
maxElementsOnDisk="10000" 磁盤最大緩存數(shù)
diskPersistent="false" 磁盤持久化
diskExpiryThreadIntervalSeconds="120" 磁盤緩存的清理線程運(yùn)行間隔
memoryStoreEvictionPolicy="FIFO" 緩存清空策略
FIFO 先進(jìn)先出
LFU less frequently used 最少使用
LRU least recently used 最近最少使用
/>
-->
<cache name="testCache"
maxEntriesLocalHeap="2000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true"
memoryStoreEvictionPolicy="FIFO">
</cache>
</ehcache>
文章來源:http://www.zghlxwxcb.cn/news/detail-601497.html
到了這里,關(guān)于變更緩存供應(yīng)商EHCACHE的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!