Hibernate EHCache vs MemCache

こ雲淡風輕ζ 提交于 2020-01-10 08:26:07

问题


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:


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/



来源:https://stackoverflow.com/questions/14029366/hibernate-ehcache-vs-memcache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!