+1
Daily
+13
Weekly
+56
Monthly
17,946
stars
1,721
forks
355
watchers
1,059
prs
795
issues
75
releases
README
Caffeine is a [high performance][benchmarks], [near optimal][efficiency] caching library. For more
details, see our [user's guide][users-guide] and browse the [API docs][javadoc] for the latest
release.
Cache
Caffeine provides an in-memory cache using a Google Guava inspired API. The improvements draw on our
experience designing [Guava's cache][guava-cache] and [ConcurrentLinkedHashMap][clhm].
java
LoadingCache graphs = Caffeine.newBuilder()
.maximumSize(10_000)
.expireAfterWrite(Duration.ofMinutes(5))
.refreshAfterWrite(Duration.ofMinutes(1))
.build(key - createExpensiveGraph(key));
Features at a Glance
Caffeine provides flexible construction to create a cache with a combination of the following
optional features:
[automatic loading of entries][population] into the cache, optionally asynchronously
[size-based eviction][size] when a maximum is exceeded based on [frequency and recency][efficiency]
[time-based expiration][time] of entries, measured since last access or last write
[asynchronously refresh][refresh] when the first stale request for an entry occurs
keys automatically wrapped in [weak references][reference]
values automatically wrapped in [weak or soft references][reference]
[notification][listener] of evicted (or otherwise removed) entries
[writes propagated][compute] to an external resource
accumulation of cache access [statistics][statistics]
In addition, Caffeine offers the following extensions:
[JSR-107 JCache][jsr107]
[Guava adapters][guava-adapter]
[Simulation][simulator]
Use Caffeine in a community provided integration:
[Spring Cache][spring]: Simple, modern, productive Java
[Play Framework][play]: High velocity web framework
[Micronaut][micronaut]: A modern, full-stack framework
[Coroutines][caffeine-coroutines]: Kotlin Coroutines extension
[Bootique][bootique]: A fast, simple Java platform
[Quarkus][quarkus]: Supersonic Subatomic Java
[Camel][camel]: Routing and mediation engine
[Scaffeine][scaffeine]: Scala wrapper for Caffeine
[JHipster][jhipster]: Generate, develop, deploy
[Aedile][aedile]: Kotlin wrapper for Caffeine
Powering infrastructure near you:
[Dropwizard][dropwizard]: Ops-friendly, high-performance, RESTful APIs
[Cassandra][cassandra]: Manage massive amounts of data, fast
[Coherence][coherence]: Mission critical in-memory data grid
[Accumulo][accumulo]: A sorted, distributed key/value store
[Kafka][kafka]: A distributed event streaming platform
[HBase][hbase]: A distributed, scalable, big data store
[Apache Solr][solr]: Blazingly fast enterprise search
[Infinispan][infinispan]: Distributed in-memory data grid
[Redisson][redisson]: Ultra-fast in-memory data grid
[OpenWhisk][open-whisk]: Serverless cloud platform
[Corfu][corfu]: A cluster consistency platform
[Grails][grails]: Groovy-based web framework
[Finagle][finagle]: Extensible RPC system
[Neo4j][neo4j]: Graphs for Everyone
[Druid][druid]: Real-time analytics
In the News
An in-depth descripTop issues
Discussions
#2024Caffeine in a CodeLaser <> Claude Code benchmark2 comments · 2026-10-12#2001AsyncLoadingCache: ThreadLocal propagation and Request Coalescing3 comments · 2026-08-19#1961Pluggable simulator policies: register external Policy classes without editing Registry.java1 comments · 2026-05-29#1952ensuring a failed async mapping is cleared before retrying1 comments · 2026-04-10#1937Handling reentrant computations1 comments · 2026-01-05#1935Confused about sync vs async refresh1 comments · 2025-11-26#1933When using expireAfter to set per-entry TTLs, is it impossible to read an entry’s TTL?1 comments · 2025-11-03#1930Putting the native GraalVM configs in the main jar?2 comments · 2025-10-28
Latest release
3.3.1 v3.3.1 2026-10-13- Added a workaround for ForkJoinPool queue corruption caused by resubmitting a reusable ForkJoinTask (2021) - Improved JCache read performance when using access expiration - Fixed various minor issues found using AI audits