EHC ❯ Inefficient shutdown of non-persistent diskstore (re-opened)
-
Bug
-
Status: New
-
-
Resolution:
-
-
-
drb
-
Reporter: riccardo
-
December 03, 2014
-
0
-
Watchers: 1
-
December 03, 2014
-
Description
A cache configured for overflowToDisk invokes MemoryStore.flush() from Cache.dispose() when CacheManager.shutdown() is invoked. This causes all in-memory entries to be flushed to disk. However when DiskStore is disposed of unless this store is marked as persistent the data files are deleted. This causes unnecessary delay to the shutdown process. MemoryStore.dispose() needs to bypass the call to flush() unless the cache.isDiskPersistent().
Sourceforge Ticket ID: 1888993 - Opened By: nobody - 7 Feb 2008 18:56 UTC
Cloned this issue from EHC-292 as I do not have permissions to re-open that ticket. I can confirm that this issue still exists as of release +2.9.0+.
It is actually very easy to spot the issue in the code. When {{CacheManager#shutdown}} is invoked on a +*non-persistent*+ cached, backed by a {{DiskStore}} (just like it would occur when choosing a _localTempSwap_ persistence strategy), the entire contents of the cache are flushed to disk when the cache is shut down.
From _net.sf.ehcache.store.CacheStore_:
and _net.sf.ehcache.store.disk.DiskStore_:
and _net.sf.ehcache.store.disk.DiskStorageFactory_:
There is clearly no test on whether the cache is persistent or not, hence the inefficient shutdown.