第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

timetoliveseconds ehcache spring boot 配置不起作用

timetoliveseconds ehcache spring boot 配置不起作用

喵喵時(shí)光機(jī) 2021-08-19 17:32:50
下面是我的 ehcache 配置文件<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:noNamespaceSchemaLocation="ehcache.xsd"    updateCheck="true"    monitoring="autodetect"    dynamicConfig="true">    <diskStore path="java.io.tmpdir" />    <cache name="trans"        maxEntriesLocalHeap="10000"        maxEntriesLocalDisk="1000"        eternal="false"        diskSpoolBufferSizeMB="20"        timeToIdleSeconds="0"        timeToLiveSeconds="6"        memoryStoreEvictionPolicy="LFU"        transactionalMode="off">        <persistence strategy="localTempSwap" />    </cache>    </ehcache>所有 Spring 注釋和配置都正常工作@Component@CacheConfig(cacheNames = {"trans" })public class MyTransService {    private List<Trans> list;    @Autowired    private EhCacheCacheManager manage;    @PostConstruct    public void setup() {        list = new ArrayList<>();    }    @CachePut    public void addTransaction(Trans trans) {        this.list.add(trans);    }    @CacheEvict(allEntries = true)    public void deleteAll() {        this.list.clear();    }    }但是在timetoliveseconds之后緩存沒有得到清除。有人可以幫助我我的配置有什么問題嗎?下面的頁面說這是錯(cuò)誤,但不知道如何解決這個(gè)問題?我使用的是 spring-boot-starter-cache-2.0.3 版本https://github.com/ehcache/ehcache-jcache/issues/26有一些類似的問題,但沒有提供任何解決方案
查看完整描述

2 回答

?
慕姐4208626

TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超7個(gè)贊

如果您希望緩存內(nèi)容在沒有交互的情況下消失,那確實(shí)不會(huì)發(fā)生。Ehcache 沒有對(duì)過期項(xiàng)目的背景檢查,可以急切地刪除它們。

而是內(nèi)聯(lián)刪除過期項(xiàng)目,無論何時(shí)您嘗試訪問它們,或者如果在寫入緩存期間,由于緩存已滿,驅(qū)逐開始。


查看完整回答
反對(duì) 回復(fù) 2021-08-19
?
喵喔喔

TA貢獻(xiàn)1735條經(jīng)驗(yàn) 獲得超5個(gè)贊

能夠使用 ehcache-JSR-107 包裝器解決此問題。下面是java配置


@Component

public class CachingSetup implements JCacheManagerCustomizer {


     @Override

     public void customize(CacheManager cacheManager)

     {

       cacheManager.createCache("trans", new MutableConfiguration<>()

         .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(SECONDS, 10)))

         .setStoreByValue(false)

         .setStatisticsEnabled(true));

     }

}

絨球


<dependencies>

        <dependency>

          <groupId>org.springframework.boot</groupId>

          <artifactId>spring-boot-starter-cache</artifactId> <!--Starter for using Spring Framework's caching support-->

        </dependency>           

        <dependency>

          <groupId>javax.cache</groupId> <!-- JSR-107 API-->

          <artifactId>cache-api</artifactId>

        </dependency>

        <dependency>

          <groupId>org.ehcache</groupId>

          <artifactId>ehcache</artifactId>

          <version>3.0.0</version>

        </dependency>

    </dependencies>


查看完整回答
反對(duì) 回復(fù) 2021-08-19
  • 2 回答
  • 0 關(guān)注
  • 418 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)