ehcache / ehcache3

Ehcache 3.x line
http://www.ehcache.org
Apache License 2.0
2k stars 579 forks source link

How to ensure that the cache is not cleared and can be read even after the application restarts? #3184

Closed xiaolongzuo closed 1 year ago

xiaolongzuo commented 1 year ago

As stated in the title, I am using version 3.10 of ehcache. After caching some data, I restart the application and the data is gone. However, I have made the following settings. resourcePoolsBuilder = ResourcePoolsBuilder.newResourcePoolsBuilder() .heap(ehCacheSorStoreConfig.getHeapSize(), MemoryUnit.MB) .disk(ehCacheSorStoreConfig.getDiskSize(), MemoryUnit.MB, true);

xiaolongzuo commented 1 year ago

I searched all the documents but couldn't find any information about persistence.Why?

xiaolongzuo commented 1 year ago

Is anyone there?

chrisdennis commented 1 year ago

You filed this issue at 7:40AM in my timezone. One minute later you asked "Is anyone there?" This isn't a commercial support channel.

This section (https://www.ehcache.org/documentation/3.10/getting-started.html#three-tiers) in the documentation describes how to configure a persistent cache. The other important point to note here is that the open source disk store requires that you cleanly shutdown the cache manager in order for persistence to work. If you don't call shutdown on the cache manager, or fail to wait for it to complete then the persistent data will be deleted on startup as it is not known to be clean (and therefore safe). If this is happening then it should be captured in the logging output on startup.

Further details on the disk store can be found here: https://www.ehcache.org/documentation/3.10/tiering.html#disk-tier