Skip to main content
Caffeine is published to Maven Central and can be easily added to your project using your preferred build tool.

Requirements

Caffeine has different version requirements based on your Java version:
Java 11 or above: Use Caffeine version 3.x
Java 8: Use Caffeine version 2.x
The current stable version is 3.2.3.

Maven

Add Caffeine to your pom.xml:
<dependency>
  <groupId>com.github.ben-manes.caffeine</groupId>
  <artifactId>caffeine</artifactId>
  <version>3.2.3</version>
</dependency>

Gradle

Kotlin DSL

Add Caffeine to your build.gradle.kts:
dependencies {
    implementation("com.github.ben-manes.caffeine:caffeine:3.2.3")
}

Groovy DSL

Add Caffeine to your build.gradle:
dependencies {
    implementation 'com.github.ben-manes.caffeine:caffeine:3.2.3'
}

Manual download

You can manually download JARs from Maven Central:
  1. Visit Maven Central
  2. Select version 3.2.3 (or latest)
  3. Download the JAR file
  4. Add to your project’s classpath

Snapshot builds

Want to try the latest development features? Snapshot builds are available from Sonatype’s snapshot repository.
To use snapshot builds, add the Sonatype snapshot repository:
<repositories>
  <repository>
    <id>sonatype-snapshots</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.github.ben-manes.caffeine</groupId>
    <artifactId>caffeine</artifactId>
    <version>3.2.4-SNAPSHOT</version>
  </dependency>
</dependencies>

Optional extensions

Caffeine offers optional extensions for additional functionality:

Guava adapter

Provides adapters to use Caffeine as a drop-in replacement for Guava’s cache:
<dependency>
  <groupId>com.github.ben-manes.caffeine</groupId>
  <artifactId>guava</artifactId>
  <version>3.2.3</version>
</dependency>
This allows you to migrate from Guava’s cache to Caffeine with minimal code changes.

JCache (JSR-107)

Provides JSR-107 JCache API compatibility:
<dependency>
  <groupId>com.github.ben-manes.caffeine</groupId>
  <artifactId>jcache</artifactId>
  <version>3.2.3</version>
</dependency>
Use this if your application requires the standard Java Caching API.

Verify installation

Verify Caffeine is correctly installed by creating a simple cache:
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;

public class VerifyInstallation {
    public static void main(String[] args) {
        Cache<String, String> cache = Caffeine.newBuilder()
            .maximumSize(100)
            .build();
        
        cache.put("hello", "world");
        System.out.println(cache.getIfPresent("hello")); // Prints: world
    }
}
If this compiles and runs without errors, Caffeine is successfully installed.

Next steps

Quick start guide

Build your first cache with step-by-step examples

Build docs developers (and LLMs) love