OSCache vs. EHCache

2020-02-21 13:51发布

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?

10条回答
相关推荐>>
2楼-- · 2020-02-21 14:01

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.

查看更多
Animai°情兽
3楼-- · 2020-02-21 14:03

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.

查看更多
smile是对你的礼貌
4楼-- · 2020-02-21 14:07

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.

查看更多
爷、活的狠高调
5楼-- · 2020-02-21 14:08

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.

查看更多
甜甜的少女心
6楼-- · 2020-02-21 14:13

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.

查看更多
贪生不怕死
7楼-- · 2020-02-21 14:14

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.

查看更多
登录 后发表回答