Hibernate EHCache vs MemCache
Asked Answered
S

1

14

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 !!

Scandent answered 25/12, 2012 at 9:26 Comment(0)
L
14

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/

Lani answered 25/12, 2012 at 9:37 Comment(2)
Can you please share your experience of using EHCache vs MemCached with scalable apps with clustering ?Scandent
I have used only EHCache in a Rackspace virtual cluster. The important thing to note here is the cache isn't shared. Every machine has its own cache. If this is OK for your architecture, then use either Memcached or EHcache. I have used Memcached for only small projects so I don't have a thorough knowledge or experience with it, but it seemed pretty much the same.Lani

© 2022 - 2024 — McMap. All rights reserved.