OSCache 与 EHCache
Never used a cache like this before. The problem is that I want to load 500,000 + records out of a database and do some selecting/filtering wicked fast.
I'm thinking about using a cache, and preliminarily found EHCache and OSCache, any opinions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
它们都是非常可靠的项目。 如果您有非常基本的缓存需求,那么其中任何一个都可能与另一个一样有效。
如果可行的话,您可能还希望考虑在数据库查询中进行过滤。 通常,使用返回较小结果集的优化查询会比将 500,000 行加载到内存中然后过滤它们提供更好的性能。
They're both pretty solid projects. If you have pretty basic caching needs, either one of them will probably work as well as the other.
You may also wish to consider doing the filtering in a database query if it's feasible. Often, using a tuned query that returns a smaller result set will give you better performance than loading 500,000 rows into memory and then filtering them.
从他们的发布页面来看,OSCache 自 2007 年以来就没有得到积极维护。这不是一个好东西。 另一方面,EhCache 正在不断发展。 仅出于这个原因,我就会选择 EhCache。
2013 年 11 月编辑:OSCache 和 OpenSymphony 的其他部分一样,已经死了。
Judging by their releases page, OSCache has not been actively maintained since 2007. This is not a good thing. EhCache, on the other hand, is under constant development. For that reason alone, I would choose EhCache.
Edit Nov 2013: OSCache, like the rest of OpenSymphony, is dead.
我在几个带有 spring-modules 的 spring 项目中使用了 oscache,使用基于 aop 的配置。
最近我想在 Spring 3.x 项目上使用 oscache + spring 模块,但发现不支持 spring-modules 基于注释的缓存(即使是 fork)。
我最近发现了这个项目 -
http://code.google.com/p /ehcache-spring-annotations/
它支持 spring 3.x,使用 ehcache 进行基于声明性注释的缓存。
I have used oscache on several spring projects with spring-modules, using the aop based configuration.
Recently I looked to use oscache + spring modules on a Spring 3.x project, but found spring-modules annotation-based caching is not supported (even by the fork).
I recently found out about this project -
http://code.google.com/p/ehcache-spring-annotations/
Which supports spring 3.x with declarative annotation-based caching using ehcache.
不管怎样,我建议将它们与 Spring 模块一起使用。
缓存对于应用程序来说是透明的,并且缓存实现非常容易交换。
除了OSCache和EHCache之外,Spring Modules还支持Gigaspaces和JBoss缓存。
至于比较....
OSCache更容易配置
EHCache有更多的配置选项
它们都坚如磐石,都支持镜像缓存,都与Terracotta一起工作,都支持内存和磁盘缓存。
Either way, I recommend using them with Spring Modules.
The cache can be transparent to the application, and cache implementations are trivially easy to swap.
In addition to OSCache and EHCache, Spring Modules also support Gigaspaces and JBoss cache.
As to comparisons....
OSCache is easier to configure
EHCache has more configuration options
They are both rock solid, both support mirroring cache, both work with Terracotta, both support in-memory and to-disk caching.
其他答案讨论了缓存的优缺点; 但我想知道你是否真的从缓存中受益。 目前还不太清楚您打算在这里做什么,以及为什么缓存会很有用:如果您有可用的数据集,只需访问它即可。 缓存仅有助于在其他独立任务之间重用事物。 如果这就是您正在做的事情,那么缓存可以提供帮助。 但如果这是一项需要携带数据集的大型任务,那么缓存就不会增加任何价值。
Other answers discuss pros/cons for caches; but I am wondering whether you actually benefit from cache at all. It is not quite clear exactly what you plan on doing here, and why a cache would be beneficial: if you have the data set at your use, just access that. Cache only helps reuse things between otherwise independent tasks. If this is what you are doing, yes, caching can help. But if it is a big task that can carry along its data set, caching would add no value.
选择符合 JSR 107 的缓存,当您想要从一种实现迁移到另一种实现时,这将使您的工作变得轻松。 具体来说,Ehcache 是更流行且广泛使用的 Java 缓存解决方案。 我们广泛使用 Ehcache,它对我们很有用。
Choose a cache which complies to JSR 107 which will make your job easy when you want to migrate from one implementation to the other. To be specific on the question go for Ehcache which is more popular and widely used Java caching solution. We are using Ehcache extensively and it works for us.
我使用过 JCS (http://jakarta.apache.org/jcs/),看起来可靠且易于编程使用。
I've used JCS (http://jakarta.apache.org/jcs/) and it seems solid and easy to use programatically.
这在某种程度上取决于您的需求。 如果您在一台机器上的内存中进行工作,那么 ehcache 将完美工作,假设您有足够的 RAM 或足够快的硬盘,这样溢出就不会导致磁盘分页/抖动。 如果您发现需要实现可扩展性,即使这种特定操作发生了很多,那么您可能会想要进行集群。 JBoss 的 JGroups /TreeCache 支持这一点,EHcache 也支持这一点(我认为),而且我知道如果您将 Ehcache 与 terracotta 一起使用,它肯定会起作用,这是一个非常巧妙的集成。 这个答案并没有直接说明EHcache和OSCache的优点,所以答案如下:EHcache似乎具有最大的惯性(曾经是默认的,众所周知的,积极开发,包括新的缓存服务器),而OSCache似乎(至少在某一点上)拥有稍微更多的功能,但我认为通过上面提到的选项,这些优点已经没有实际意义/被取代了。 啊,我忘记提及的另一件事是数据的事务性很重要,您的要求将完善有效选择的列表。
It sort of depends on your needs. If you're doing the work in memory on one machine, then ehcache will work perfectly, assuming you have enough RAM or a fast enough hard disk so that the overflow doesn't cause disk paging/thrashing. if you find you need to achieve scalability, even despite this particular operation happening a lot, then you'll probably want to do clustering. JGroups /TreeCache from JBoss support this, so does EHcache (I think), and I know it definitely works if you use Ehcache with terracotta, which is a very slick integration. This answer doesn't speak directly to the merits of EHcache and OSCache, so here's that answer: EHcache seems to have the most inertia (used to be the default, well known, active development, including a new cache server), and OSCache seemed (at least at one point) to have slightly more features, but I think that with the options mentioned above those advantages are moot/superseded. Ah, the other thing I forgot to mention is that transactionality of the data is important, and your requirements will refine the list of valid choices.
OSCache 几乎已经死了,因为它在几年前就被废弃了。 您可以看看 Cacheonix,它一直在积极开发中,我们刚刚发布了 v.2.2.2,支持 Web 层的缓存。 我是一名提交者,因此如果您有任何疑问,可以与我联系。
OSCache is pretty much dead as it has been abandoned a few years ago. You may take a look at Cacheonix, it's been actively developed and we've just released v.2.2.2 with support for caching in the web tier. I'm a committer so you can reach out if you have any questions.
我主要使用 EhCache,因为它曾经是 Hibernate 的默认缓存提供程序。 Java-Source.net 上有一个缓存解决方案列表。
我曾经有一个比较主要缓存解决方案的链接。 如果我找到它,我会更新这个答案。
I mainly use EhCache because it used to be the default cache provider for Hibernate. There is a list of caching solutions on Java-Source.net.
I used to have a link that compared the main caching solutions. If I find it I will update this answer.