caffeine README

The project's README from github.com/ben-manes/caffeine. As one markdown file: README.md.

Build Status Test Count Coverage Status Maven Central JavaDoc License Revved up by Develocity

Caffeine is a high performance, near optimal caching library. For more details, see our user's guide and browse the API docs 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 and ConcurrentLinkedHashMap.

LoadingCache<Key, Graph> 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:

In addition, Caffeine offers the following extensions:

Use Caffeine in a community provided integration:

Powering infrastructure near you:

In the News

Download

Download from Maven Central or depend via Gradle:

implementation("com.github.ben-manes.caffeine:caffeine:3.2.4")

// Optional extensions
implementation("com.github.ben-manes.caffeine:guava:3.2.4")
implementation("com.github.ben-manes.caffeine:jcache:3.2.4")

For Java 11 or above, use 3.x otherwise use 2.x.

See the release notes for details of the changes.

Snapshots of the development version are available in Sonatype's snapshots repository.

caffeine (ben-manes/caffeine)

Searching Database…

17.9K ·GitHub
What is this?Caffeine is a high-performance, near-optimal in-memory caching library for Java with a Guava-inspired API.
Is this an in-process cache or a separate caching server like Redis?It's purely an in-process, in-memory cache you embed in your Java app, not a standalone server like Redis or Memcached.
How do I add it to my project?Pull the caffeine artifact from Maven Central or add it as a Gradle dependency.
Which Java version do I need?Use the 3.x line if you're on Java 11 or newer; stick with 2.x for older Java versions.
Does Caffeine handle caching across multiple servers?No, it's a single-JVM in-memory cache; for distributed caching you'd pair it with a data grid like Infinispan, which several listed integrations already do.
Do I need to already use Guava to benefit from this?No, Caffeine's API is just inspired by Guava's cache, but it's standalone and even ships Guava adapters for compatibility with existing Guava-based code.
What eviction policy does Caffeine use?It uses an adaptive, near-optimal eviction policy based on TinyLFU (Tiny Least Frequently Used), described in research papers co-authored by the project's creator.
Which frameworks have Caffeine integrations?Community integrations exist for Spring Cache, Play Framework, Micronaut, Quarkus, Camel and JHipster, plus Kotlin wrappers (Aedile, Kotlin Coroutines) and the Scaffeine wrapper for Scala.
Who uses Caffeine in production?It powers caching layers inside Cassandra, HBase, Solr, Kafka, Infinispan, Dropwizard, Accumulo, Corfu, Neo4j and Druid, among others.
Can Caffeine report cache usage stats?Yes, it can accumulate cache access statistics like hit and miss rates for monitoring cache effectiveness.
Creator
ben-manes
Size
114.9 MB
Stars
17.9K
Age
11y
Commits · 90 Days