Over a million developers have joined DZone.

Shutting Down Ehcache Properly

· Java Zone

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

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.

<listener>
<listener-class>net.sf.ehcache.constructs.web.ShutdownListener</listener-class>
</listener>

Alternatively, or when not using ehcache inside a webapp, instruct ehcache to register its own shutdown hook by setting a system property.

net.sf.ehcache.enableShutdownHook=true

If you forget one of the above, your persisted cache may not be up-to-date, or worse, not persisted at all.

From http://codeaweso.me/2010/01/shutting-down-ehcache-properly/

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}