Viktor
Viktor

Reputation: 1487

shutdown ehcache CahceManager in stateless bean

I would like to use ehcache in stateless EJB. As I know if I get a singleton instance of CacheManager then I have to shutdown this instance when I don't need it. However it causes a big overhead for me as a lot of time is needed to create the CacheManager instance if I shutdown it at each call. Or shouldn't I bother to shutdown the CacheManager in EJB? Won't it cause any issue?

Thanks!

Upvotes: 0

Views: 222

Answers (1)

lanimall
lanimall

Reputation: 451

Per EhCache documentation (http://ehcache.org/documentation/operations/shutdown) it's a good practice (and in some case required practice) to shutdown EhCache properly.

Either way, Should be easy to implement: I think you should register a shutdown hook for your EJB (check post EJB application shutdown hook) and in that hook, simply call the CacheManager.shutdown() method.

Hope that helps.

Upvotes: 1

Related Questions