guava cache vs ehcache benchmark

Raul picture Raul · Dec 18, 2012 · Viewed 19k times · Source

I'm trying to decide which of these two to use in my project: guava cache or ehcache. Looking for a lightweight service level caching solution. I've searched for some benchmarks, but couldn't find any.

If you've have a benchmark handy, please post it here.

Cheers.

Answer

mindas picture mindas · Dec 18, 2012

Benchmarking is a slippery business. It's hard to get it right and easy to fake. Unless your app will squeeze out every CPU cycle out of metal, you shouldn't be worried about performance: both Ehcache and guava cache are good enough for an average project.

Things you should be paying attention are API and features. For example, Guava cache can not be used as 2nd level Hibernate cache (that is, at least out of the box). OTOH Ehcache has grown a little bit fat in terms of API and feature creeping but these things are subjective.

Coming back on topic, Guava cache was originally pulled from a separate project, concurrentlinkedhashmap which, I believe, is no longer supported as such is just a one-man project and lost a bit of momentum (see the comment below this post). Nevertheless, old project page still has some benchmarks proving ConcurrentHashMap (now guava Cache) performance being close to ConcurrentLinkedHashMap. I hope it didn't deteriorate.