ben-manes

ben-manes/caffeine

Java Apache-2.0 Dev Tools

A high performance caching library for Java

17.8k stars
1.7k forks
active
GitHub +14 / week

17.8k

Stars

1.7k

Forks

1

Open issues

30

Contributors

v3.2.4 03 May 2026

AI Analysis

Caffeine is a high-performance, in-memory caching library for Java that provides automatic loading, size-based eviction, time-based expiration, and asynchronous refresh capabilities. It serves Java developers building applications requiring low-latency cache operations with flexible eviction policies, and is particularly valuable for teams migrating from or extending Google's Guava cache. Not intended for distributed caching scenarios or cache systems that require cross-process sharing.

Dev Tools Library Discovery value: 2/10
Documentation 9/10
Activity 9/10
Community 9/10
Code quality 9/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 9/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

caching java-performance memory-management eviction-policies concurrent-data-structures
Actively maintained Well documented Popular Niche/specialized use case Production ready
Deep Analysis · Based on README and public signals
2w ago

Caffeine: Java's de-facto in-process cache library, backed by near-optimal eviction algorithms

Caffeine is a high-performance, in-memory caching library for Java that implements the W-TinyLFU eviction policy, offering near-optimal hit rates with low overhead. It is used across a wide range of production systems including Apache Kafka, Cassandra, Neo4j, Apache Solr, Druid, and many others. Built as a spiritual successor to Guava's cache, it targets Java backend developers who need a reliable, zero-dependency local cache with flexible expiration, async loading, weak/soft reference support, and JCache (JSR-107) compatibility. It is integrated into Spring, Quarkus, Micronaut, and other major Java frameworks.

Origin

Created in December 2014 by Ben Manes, who had previously built ConcurrentLinkedHashMap and contributed to Guava's cache. Caffeine formalized and extended research into TinyLFU eviction policies, co-authoring academic papers on the algorithm.

Growth

Growth has been steady and organic, driven by adoption in foundational Java infrastructure (Kafka, Cassandra, Solr) and first-class integration in major frameworks (Spring Boot, Quarkus, Micronaut). The Guava cache migration path lowered adoption friction significantly. Stars accumulate slowly but consistently — approximately 16 per week as of mid-2026 — reflecting a mature library rather than a trending project. Adoption is usage-driven, not hype-driven.

In production

Extensive documented production usage: Apache Kafka, Cassandra, HBase, Apache Solr, Neo4j, Druid, Infinispan, Redisson, Finagle, OpenWhisk, and Coherence all list Caffeine as an infrastructure dependency. Spring Cache, Quarkus, and Micronaut ship Caffeine as a first-class cache provider. This constitutes among the strongest adoption evidence visible for any JVM library.

Code analysis
Architecture

Appears to implement a concurrent, non-blocking cache backed by the W-TinyLFU policy (Window Tiny Least Frequently Used), which combines a frequency sketch with recency awareness. Likely uses a lock-free or low-contention amortized write-buffer design for high throughput. Supports synchronous and asynchronous cache loading, multiple eviction dimensions (size, time, references), and listener callbacks. Extensions for JCache and Guava adapter are modularized as separate artifacts.

Tests

Coverage is tracked via Coveralls and shown as a badge in the README. Based on the presence of a test-count badge linked to CI runs, the project appears to have an extensive automated test suite. Exact coverage percentage is not stated in the README excerpt, but the infrastructure signals active quality maintenance.

Maintenance

Last push was 2026-06-26 — the same day as the analysis date — indicating active, ongoing development. CI is configured via GitHub Actions. The project uses Develocity (Gradle build scanning). Version 3.2.4 is current for Java 11+, with a separate 2.x line maintained for older Java. These signals collectively indicate a well-maintained, actively developed project with no signs of abandonment.

Honest verdict

ADOPT IF: you need a high-performance, in-process Java cache with flexible eviction, async loading, and framework integration — this is the standard choice for JVM local caching and has proven production pedigree. AVOID IF: you need distributed, multi-node, off-heap, or persistent caching — Caffeine is strictly in-process and in-heap; a distributed cache or data grid is required for those scenarios. MONITOR IF: you are evaluating multi-level cache architectures where Caffeine would serve as the L1 tier alongside a remote store — the integration ecosystem continues to evolve.

Independent dimensions

Mainstream potential

7/10

Technical importance

9/10

Adoption evidence

10/10

Risks
  • Single maintainer dependency: the project is primarily maintained by Ben Manes. Bus-factor risk exists, though the codebase appears mature and the license is permissive.
  • In-heap only: all cached data consumes JVM heap, which can increase GC pressure at large cache sizes. Off-heap alternatives may be needed for very large caches.
  • Not a distributed cache: teams that eventually need cross-node consistency or replication will need to add a separate layer; Caffeine does not scale horizontally.
  • Java-only: no official support for other JVM languages beyond community wrappers (Scala's Scaffeine, Kotlin's Aedile). Teams on non-JVM stacks need different solutions.
  • Complexity of advanced features: async refresh, compute, and write-propagation behaviors can be subtle to configure correctly under concurrent load; misconfigurations may produce non-obvious results.
Prediction

Caffeine is likely to remain the default local cache choice for Java/JVM applications for the foreseeable future. Adoption will continue to grow incrementally as the Java ecosystem grows, with no credible challenger currently visible.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

Java
95.7%
Python
3.8%
Kotlin
0.3%
Shell
0.2%

Information

Language
Java
License
Apache-2.0
Last updated
2d ago
Created
141mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Similar repos

alibaba

alibaba/jetcache

JetCache is a Java caching abstraction layer that unifies access across...

5.6k Java Dev Tools
ehcache

ehcache/ehcache3

Ehcache 3.x is a Java-based distributed caching solution designed for...

2.1k Java Dev Tools
aeron-io

aeron-io/agrona

Agrona is a specialized library of high-performance data structures and...

3.2k Java Dev Tools
CaffeineMC

CaffeineMC/lithium

Lithium is a free, open-source Minecraft mod that optimizes game performance on...

2.1k Java Gaming
memcached

memcached/memcached

Memcached is a high-performance, multithreaded, event-based distributed...

14.2k C DevOps
vs. alternatives
Guava Cache (Google Guava)

Caffeine is the acknowledged successor; Guava cache is widely considered deprecated for caching use cases. Caffeine offers better hit rates, higher throughput, and async loading. Caffeine provides a Guava adapter for drop-in compatibility.

ehcache3

Ehcache targets enterprise use cases with off-heap, disk persistence, and clustering. Caffeine is strictly in-process and in-heap, making it simpler, faster, and lower overhead. They serve overlapping but distinct needs; Caffeine is often used alongside distributed caches rather than as a replacement.

alibaba/jetcache

JetCache provides a higher-level annotation-driven caching abstraction with multi-level (local + remote) cache support, targeting Spring applications. Caffeine can be used as JetCache's local tier. JetCache is framework-opinionated; Caffeine is a lower-level primitive.

Netflix/EVCache

EVCache is a distributed, Memcached-based cache designed for multi-region Netflix infrastructure. It solves a fundamentally different problem — remote distributed caching at scale — whereas Caffeine is an in-process cache. They are complementary rather than competing.

Infinispan

Infinispan is a full distributed in-memory data grid supporting clustering, persistence, and transactions. Caffeine is embedded and local only. Notably, Infinispan itself uses Caffeine internally for its local caching layer, illustrating the complementary relationship.