cache2k vs Ehcache
cache2k
cache2k.orgEhcache
ehcache.orgSide by side
| Figure | cache2k | Ehcache |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | Yes |
| Linux | Yes | — |
| Android | Yes | — |
| API | Yes | Yes |
| Self-hosted | Yes | Yes |
| Plans published | 1 | 3 |
| Spec score · Caching Software | 8.1 (#6) | 8.5 (#4) |
| Purpose | cache2k is an in-memory object caching library for Java applications. | Ehcache is an open-source, standards-based Java cache that boosts performance, offloads databases, and simplifies scalability. |
| Support | The project directs bug reports and feature requests to GitHub issues and general usage questions to the cache2k Stack Overflow tag. | Ehcache documentation directs users with unanswered questions to its support forums. |
Plans
In their own words
cache2k
cache2k is an Apache-licensed, open-source library that keeps Java application objects in memory. Its project describes a JAR smaller than 400 KB with no external dependencies, and the implementation is written in pure Java without sun.misc.Unsafe. Cache behavior includes automatic expiry, refresh, refresh ahead, read-through loading, and event listeners. Cache loaders can suppress exceptions or retry them according to configuration. Integrations listed include Spring Framework, Scala Cache, DataNucleus through JCache, and Hibernate through JCache. cache2k supports JCache / JSR 107, while its guide notes extra overhead for that API compared with the native interface. Monitoring options include low-overhead statistics, JMX, and documented Micrometer metrics. Version 2 requires Java 8 or later and is described as compatible with Android API level 26. The library is free, available from Maven Central, self-hosted, and does not persist data.
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.