cache2k vs Ristretto
cache2k
cache2k.orgRistretto
github.comSide by side
| Figure | cache2k | Ristretto |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | — |
| Windows | — | Yes |
| macOS | — | Yes |
| Linux | Yes | Yes |
| Android | Yes | — |
| API | Yes | — |
| Self-hosted | Yes | Yes |
| Plans published | 1 | 1 |
| Spec score · Caching Software | 8.1 (#6) | 7.5 (#13) |
| License | The project says its code is released under the Apache license. | The repository is licensed under Apache License, Version 2.0. |
| Purpose | cache2k is an in-memory object caching library for Java applications. | Ristretto is a fast, concurrent, memory-bound Go cache library focused on performance and correctness. |
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.
Ristretto
Ristretto is a free, open-source Go library for an in-process cache of key-value data, designed for concurrent use, performance and correctness. It keeps data in memory in a single process rather than operating as a distributed cache. TinyLFU admission and SampledLFU eviction are paired to target high hit ratios; applications define item cost, allowing a valuable large item to displace several smaller ones. The project attributes throughput to contention management, batching and eventual consistency. Goroutines can use the cache concurrently with little throughput degradation, according to the project, and optional metrics cover throughput, hit ratios and other statistics. A Set for a new item may be dropped in the Set buffer or admission policy, while updates are guaranteed. Ristretto requires Go 1.21 or later and Go modules. Version 2 supports generics, which the project recommends for new programs. The repository is licensed under Apache License, Version 2.0, and describes the library as production-ready. Its README names Badger and Dgraph as projects using it.