Shutdown the cache and stop the autoreleaser thread
Added a way to stop the autoreleaser thread if it was started previously.
After some months (years?) on our production environment, we saw that every time we released a new version of our server application, the old one was not fully stopped. The issue was related with the Autoreleaser Thread of this cache, that was running on background. As it was active, the Servlet container let it run forever in background. And that is not as elegant as we want 🎩We want to kill those old versions of the app that were using our precious resources!
So, if you run this cache on a long life application, you could be interested in stopping it at some point. To do it, just call the new method cache.shutdown()
. In J2EE environments, ServletContextListener.contextDestroyed()
is the place to do it.
By the way, if you run it on Android, you have two ways to manage it:
1. Just keep the autoreleaser thread alive forever. Android will kill your app at some point, so ignore it.
2. If you love elegance 🎩as us, you have to bother about it only if you store big objects on the cache. If you do that, you should build the cache with the autoreleaser to successfully free the memory of the dead objects from time to time. And, if you use the autoreleaser, it would be good that you shut down the cache as soon as you think that those cached objects are not going to be used anymore. By the way, if your objects are needed during all the application life, ignore all the explained: as in the point 1., Android will kill your app when it needs to do it, so let's ignore all the explained in this long release readme.
"That's all folks!"