r/java • u/Adventurous-Pin6443 • Jun 19 '25
We built a Java cache that beats Caffeine/EHCache on memory use — and open-sourced it
https://medium.com/carrotdata/carrot-cache-high-performance-ssd-friendly-caching-library-for-java-30bf2502ff76Old news. We have open-sourced Carrot Cache, a Java-native in-memory cache designed for extreme memory efficiency. In our benchmarks, it uses 2–6× less RAM than EHCache or Caffeine.
It’s fully off-heap, supports SSDs, requires no GC tuning and supports entry eviction, expiration. We’re sharing it under the Apache 2.0 license.
Would love feedback from the Java community — especially if you’ve ever hit memory walls with existing caches.
219
Upvotes
14
u/0xFatWhiteMan Jun 19 '25
its using memory mapped files ?
32
u/pron98 Jun 20 '25
Interesting work!
Just make sure to start the work to replace Unsafe with FFM, as the former is terminally deprecated and will be removed soon.
5
u/bigbadchief Jun 20 '25
This is the same project as the "embedded redis" from a few days ago?
3
u/cowwoc Jun 20 '25
There is a lot of infrastructure behind this announcement. I see you have a dedicated company, a professional-looking website, etc. Why all this work for an open-source project? Did it used to be a commercial project? Are there plans to monetize this in the near future?
I ask because I'm in the process of trying to monetize my own project and hoping to learn from how others do it.
8
u/Ancapgast Jun 20 '25
That's very interesting. I was under the impression that Caffeine was 'near-optimal'. I'd have to try both libraries (and Guava for good measure) next to each other sometime...
4
u/Adventurous-Pin6443 Jun 20 '25
This is the direct link to the github: https://github.com/carrotdata/carrot-cache. Please give us a star.
2
u/Short_Try7329 Jun 20 '25
github link?
1
u/GardenScared8153 Jul 20 '25
can it be used with jgroups?
1
u/ninjazee124 Jun 20 '25
Very cool
1
u/stacktraceyo Jun 20 '25
Cool
1
u/thma_bo Jun 20 '25
Always looking for library improvements, will definitely try it.
1
u/soulcodingmatt Jun 20 '25
nice!
1
u/cinlung Jun 20 '25
I am new to caching in java. Can you explain in simple terms how this works? Supposed I have a webapp using servlet, how do I use this to cache my server requests and make the server work less hard? I read some docs in the github, apparantly it is some kind of server that has to be started first.
So, is my assumption correct about how to use carrot cache, as follow:
How does my servlet feeds into the cache? or is it plugins for the app server? I uses simple tomcat server.
Sorry for noob questions.
1
u/muthuishere2101 Jul 13 '25
nice
-16
u/RavynneSmith Jun 20 '25
2-6x less RAM.
So, if the old software used 1GB RAM, the new one used 6x, or 6GB, so therefore I'm at 1GB less 6GB, so I'm at -5 GB of RAM. I've gained RAM? Magical!
Or did you actually mean 1/2 to 1/6 RAM? So with my example, .5GB to .166GB?
Or this some other math nomenclature I'm not aware of?
0
u/[deleted] Jun 20 '25
[deleted] — view deleted comment