Releases: fewlaps/quitnow-cache
v3.4.1
Move to Kotlin!
By the way, I did some performance tests and times are the same. That's not surprising, but hey, good to know and better to share.
Created a sexier Builder
You'll find it as QNCache.Builder()
. It looks sexier than QNCacheBuilder()
, who is now deprecated.
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!"
Add getOrDefault(key, defaultValue) to the API
Let's mimic Java 8 getOrDefault()
method. Users really missed it when using the cache, so it was time to fix it. Thanks for the patience!
Adding lots of methods to the API
.clear() instead of .replaceAll()
Welcome to common clear() method! We don't know why we had not chosen that name. Sorry 'bout that! 👍 😄
TimeUnit working also on Java 6!
This is the happy version that includes the TimeUnit powered methods also on Java 6. So, you wouldn't need to remember where to pass millis, where to pass seconds... you can also work with HOURS without doing the usual 42*1000*60*60
Incredible!
Adding TimeUnit-powered methods
... but the library only works on Java 8. Ignore this release and go on with 1.6.1 :·)
Welcome generics and happy new year 2016!
Thanks to @padilo, the QNCache is now typesafe! So you can create it like:
QNCache<String> stringCache = new QNCacheBuilder().createQNCache();