Hibernate EHCache vs MemCache

2019-02-02 11:46发布

I would like to use caching in my web application which will be scalable and distributed as well.

I have used EHCache and MemCache both in small-small web application separately.

Have googled and got mixed review about both, hence would like to get some help and strong features of each, so i can decided which framework is suitable for my web application.

Let me know if need further details.

Thanks !!

1条回答
Melony?
2楼-- · 2019-02-02 12:06

EHCache is very easy to integrate with Hibernate applications (web apps that use Hibernate as a backend ORM). You can also import it as a separate artifact and do stuff in a programmatic way, like add data to a named cache with a specified expire period or number of max objects, or size.

Memcached is not that easily integrated with hibernate applications but in essence provides almost the same API for programmatic access as the EHCache.

As far as performance goes, results will also vary depending on architecture and usage of the cache.

In conclusion, when choosing a cache, if you are using in a standard way, it is just a matter of preference which cache you are going to choose. I, personally, would choose EHCache as I have considerably more experience with it.

There is a distributed cache by JBoss as well (as in cache shared by a cluster of machines) where sync is handled internally and the API is very similar to EHCache. It is called Infinispan and is also relatively easy to set up and use.

EDIT:

As a strong feature of EHCache, I would list the seamless integration as a second-level cache for Hibernate. Also, configuring a cache in a programmatic way is very easy and Java-esque.

Maybe it is also a good idea to refer you to this for a comparison of performance. Keep in mind it's ancient, so maybe is not very up to date. http://gregluck.com/blog/archives/2007/05/comparing-memcached-and-ehcache-performance/

查看更多
登录 后发表回答