Shutting Down Ehcache Properly
If you’re using ehcache’s disk persistence feature, which allows the cache to survive across JVM restarts, be sure to shut down ehcache properly.
To do so when using ehcache within a webapp, simply add its ShutdownListener as a listener in web.xml.
Alternatively, or when not using ehcache inside a webapp, instruct ehcache to register its own shutdown hook by setting a system property.
If you forget one of the above, your persisted cache may not be up-to-date, or worse, not persisted at all.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)