Ehcache 2.10.5 | Product Documentation | Ehcache Configuration Guide | Configuring Restartability and Persistence | Cache Persistence Implementation
 
Cache Persistence Implementation
Ehcache has a RestartStore which provides fast restartability and options for cache persistence. The RestartStore implements an on-disk mirror of the in-memory cache. After any restart, data that was last in the cache will automatically load from disk into the RestartStore, and from there the data will be available to the cache.
Data persistence is configured by adding the <persistence> sub-element to a cache configuration. The <persistence> sub-element includes two attributes: strategy and synchronousWrites.
Strategy Options
The options for the strategy attribute are:
*"localRestartable" — Enables the RestartStore and copies all cache entries (on-heap and/or off-heap) to disk. This option provides fast restartability with fault tolerant cache persistence on disk. This option is available for BigMemory Go only. For more information about this strategy, see the BigMemory Configuration Guide on the Terracotta Documentation website.
*"localTempSwap" — Enables temporary local disk usage. This option provides an extra tier for storage during cache operation, but this disk storage is not persisted. After a restart, the disk tier is cleared of any cache data.
*"none" — Does not offload data to disk. With this option, all of the working data is kept in memory only. This is the default mode.
Synchronous Writes Options
If the strategy attribute is set to "localRestartable", then the synchronousWrites attribute can be configured. The options for synchronousWrites are:
*synchronousWrites="false" — This option specifies that an eventually consistent record of the data is kept on disk at all times. Writes to disk happen when efficient, and cache operations proceed without waiting for acknowledgment of writing to disk. After a restart, the data is recovered as it was when last synced. This option is faster than synchronousWrites="true", but after a crash, the last 2-3 seconds of written data may be lost.
If not specified, the default for synchronousWrites is "false".
*synchronousWrites="true" — This option specifies that a fully consistent record of the data is kept on disk at all times. As changes are made to the data set, they are synchronously recorded on disk. The write to disk happens before a return to the caller. After a restart, the data is recovered exactly as it was before shutdown. This option is slower than synchronousWrites="false", but after a crash, it provides full data consistency.
For transaction caching with synchronousWrites, soft locks are used to protect access. If there is a crash in the middle of a transaction, then upon recovery the soft locks are cleared on next access.
DiskStore Path
he path to the directory where any required disk files will be created is configured with the <diskStore> sub-element of the Ehcache configuration.For "localTempSwap", if the DiskStore path is not specified, a default path is used for the disk storage tier, and the default path will be auto-resolved in the case of a conflict with another CacheManager.

Copyright © 2010-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release