ehcache persist to disk issues

后端 未结 8 1780
你的背包
你的背包 2020-12-23 14:30

I want to do something with ehcache in Java that I think should be extremely simple, but I\'ve spent enough time frustrating myself with the docs...

  1. Write a

8条回答
  •  无人及你
    2020-12-23 15:08

    This took me a while to figure out, but basically what needs to be done here is creating the CacheManager accordingly.

    If you create the cache manager and the caches the same way how you created it in the xml it will work.

    net.sf.ehcache.CacheManager manager = net.sf.ehcache.CacheManager
            .create(new Configuration().diskStore(
                new DiskStoreConfiguration().path("C:/mycache")
            )
            .cache(new CacheConfiguration()
                .name(testName)
                .eternal(true)
                .maxBytesLocalHeap(10000, MemoryUnit.BYTES)
                .maxBytesLocalDisk(1000000, MemoryUnit.BYTES)
                .diskExpiryThreadIntervalSeconds(0)
                .diskPersistent(true)));
    

提交回复
热议问题