Caffeine vs Ehcache
Caffeine
github.comEhcache
ehcache.orgSide by side
| Figure | Caffeine | Ehcache |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | Yes |
| API | — | Yes |
| Self-hosted | Yes | Yes |
| Plans published | 1 | 3 |
| Spec score · Caching Software | 8.2 (#5) | 8.5 (#4) |
| Eviction | Size-based eviction uses frequency and recency when a configured maximum is exceeded. | The product provides configurable eviction strategies for deciding which entries leave a cache. |
| Purpose | Caffeine is a high-performance, near-optimal in-memory caching library for Java. | Ehcache is an open-source, standards-based Java cache that boosts performance, offloads databases, and simplifies scalability. |
Plans
In their own words
Caffeine
Caffeine is a free, open-source in-memory caching library for Java, distributed under the Apache License, Version 2.0. It provides an API inspired by Google Guava and can load entries automatically, including asynchronously. Size-based eviction uses configured limits with frequency and recency, while entries can expire according to time since their last access or write. When a stale entry is first requested, Caffeine can refresh it asynchronously. Other functions include weak keys, weak or soft values, removal notifications, writes to external resources, and cache statistics. The project offers JSR-107 JCache, Guava adapters, and a simulation extension, with community integrations listed for Spring Cache, Play Framework, Micronaut, Quarkus, and Apache Camel. The project directs users to Maven Central and provides Gradle coordinates for the core library and optional extensions. Version 3.x is intended for Java 11 or newer; earlier Java versions use 2.x. Maven Central artifacts are accompanied by GPG and Sigstore signature files according to the security policy.
Ehcache
Ehcache is a free, open-source Java caching library for keeping application data, database results, and web pages available to applications. It is designed to improve performance, reduce database work, and support scaling. It can run inside an application or in mixed in-process and out-of-process deployments, including terabyte-sized caches. Ehcache 3 supports off-heap storage, including configurations that rely on it exclusively, and is compatible with the JCache API defined by JSR-107. The project describes Spring Caching and Hibernate integration through javax.cache support. Configuration is available through XML or the Java API, and data can be shared between application instances using Terracotta clustered storage. Ehcache 3.11 also allows caches to share resources. It supports JTA-managed XA transactions, including two-phase commit and crash recovery, but documents Read-Committed as the only supported isolation level and Bitronix 2.1.4 as the only tested transaction manager. Ehcache 3.11 requires Java 8 or later and is the last release line to support Java 8. The license is Apache 2.0.