Spring ehcache vs Memcached?
Asked Answered
A

1

11

I have worked on spring cahing using ehcache . To me it is like same with different set of API exposed and their implementation.

What's the difference in terms of features provided between them apart from API/implementation ?

Update:- I have already seen Hibernate EHCache vs MemCache but that question is mainly from hibernate perspective but my question is in general for any caching service . Answer to that question also states there is not much difference in terms of features

Algonkian answered 24/2, 2017 at 14:42 Comment(2)
check out this question #14029866Nairobi
@neeraj i had seen this question before posting it. Actually that question is from hibernate perspective. My question is in general for any caching serviceAlgonkian
C
13

Aside from the API differences you noted, the major difference here is going to be that memcached lives in a different process while Ehcache is internal to the JVM - unless configured to store on disk or in a cluster.

This mainly means that with Memcached you always need a serialized version of your objects and you always interact with a different process, remote or not.

Ehcache, and other JVM based caching solutions, start with a on-heap based cache initially which allows lookups to be simply about handling references to your Java objects.

Of course this means that the objects keep living in the Java heap, increasing memory pressure. In the case of Ehcache 3.x you have the option to move to offheap memory and more, allowing to grow the cache without impacting JVM heap.

At this point, the benefit of Memcached may be that you want non Java clients to access it.

And the final decision really is in your hands. Caches are consuming memory to provide reduced latency. What works for you may be different than what works for others. You have to measure and decide.

Cataclysm answered 27/2, 2017 at 10:11 Comment(6)
when you say memcached lives in a different process is it mandatory ? what if i want to use with in same jvm process as in webserver ? Also you said Of course this means that the objects keep living in the Java heap, increasing memory pressure . My point is whether its ehcache or memcached, objects will be stored in heap. The only difference is in case of memcached , heap will beolng to separate process. Is n't it ?Algonkian
One last point on At this point, the benefit of Memcached may be that you want non Java clients to access it , does memcached expose the webservices to allow non java clients to access the object ?Algonkian
Memcached is not a java program. It is a standalone server. So it will never store on heap. Yes. Memcached has a proprietary API. But you still need to find a client in the language you want. Ehcache being in memory, you directly have a client (that is also used to talk to a Terracotta cluster)Confetti
@Confetti So it will never store on heap then where it will store ? Its is memory data store right ?Algonkian
Memcached will store in memory, the memory of its own process which is thus different than the Java heap.Cataclysm
Just like @LouisJacomet said. Memcached will store in memory but on another server. Not on the Java heap of your applicationConfetti

© 2022 - 2024 — McMap. All rights reserved.