Skip to content
Ben Manes edited this page Aug 29, 2015 · 21 revisions

Caffeine is a high performance Java 8 based caching library.

A Cache is similar to ConcurrentMap, but not quite the same. The most fundamental difference is that a ConcurrentMap persists all elements that are added to it until they are explicitly removed. A Cache on the other hand is generally configured to evict entries automatically, in order to constrain its memory footprint. In some cases a LoadingCache or AsyncLoadingCache can be useful even if it doesn't evict entries, due to its automatic cache loading.

Caffeine provide flexible construction to create a cache with a combination of the following features:

To improve integration, JSR-107 JCache and Guava adapters are provided in extension modules. JSR-107 standardizes a Java 6 based API to minimize vendor specific code at the cost of features and performance. Guava's Cache is the predecessor library and the adapters provide a simple migration strategy.

The tracing and simulation extensions allow for offline investigation of cache performance and tuning. For developers needing to write custom caches the variety of policies may help determine which is the best fit for a particular use-case.

Contributions are welcome. Please read the design document, developer setup guide, and roadmap.

Clone this wiki locally