java 番石榴缓存与 ehcache 基准测试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13938660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 14:31:12  来源:igfitidea点击:

guava cache vs ehcache benchmark

javabenchmarkingguavaehcache

提问by Raul

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.

我正在尝试决定在我的项目中使用这两个中的哪一个:番石榴缓存或 ehcache。寻找轻量级服务级别缓存解决方案。我搜索了一些基准,但找不到任何基准。

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

如果您手头有基准测试,请在此处发布。

Cheers.

干杯。

回答by mindas

Benchmarking is a slippery business. It's hard to get it rightand 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.

基准测试是一项非常危险的业务。这是很难得到它的权利容易伪造。除非您的应用程序将每个 CPU 周期都挤出来,否则您不必担心性能:Ehcache 和 guava 缓存对于普通项目来说都足够好。

Things you shouldbe 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.

应该注意的事情是 API 和功能。例如,Guava 缓存不能用作第二级 Hibernate 缓存(也就是说,至少开箱即用)。OTOH Ehcache 在 API 和功能蠕变方面变得有点胖,但这些都是主观的。

Coming back on topic, Guava cache was originally pulled from a separate project, concurrentlinkedhashmapwhich, I believe, is no longer supported as suchis 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.

回到主题,Guava 缓存最初是从一个单独的项目concurrentlinkedhashmap 中提取的,我相信它不再受支持,因为它只是一个单人项目并且失去了一点动力(请参阅本文下方的评论)。尽管如此,旧的项目页面仍然有一些基准测试证明ConcurrentHashMap(现在的番石榴缓存)性能接近ConcurrentLinkedHashMap. 我希望它没有恶化。