talira

Caffeine

A high performance, near optimal caching library for Java

open sourceApache-2.0self-hostablefree

Caffeine is an in-memory caching library for Java with an API inspired by Google Guava's cache, built by the designer of Guava's cache and ConcurrentLinkedHashMap. A cache is configured with a builder: automatic (optionally asynchronous) loading of entries, size-based eviction that uses both frequency and recency for a near-optimal hit rate, expiry after access or write, asynchronous refresh of stale entries, weak and soft references, removal notifications, write-through to an external resource and hit-rate statistics. Extensions add a JSR-107 JCache provider, Guava adapters and a simulator for comparing eviction policies.

Problems it solves

  • cache expensive lookups in memory in a Java service
  • evict cache entries by size or time without writing my own LRU
  • a faster replacement for Guava's cache
  • refresh cached values in the background before they go stale
  • load cache entries asynchronously with CompletableFuture
  • a JCache (JSR-107) provider for my Java application
  • measure cache hit rates in a JVM app

Features

  • automatic and asynchronous loading
  • size-based eviction by frequency and recency
  • expiry after access or write
  • asynchronous refresh
  • weak keys and weak or soft values
  • removal listeners
  • write propagation to external resources
  • statistics
  • JSR-107 JCache extension
  • Guava adapters
View 1 more
  • eviction policy simulator

Capabilities

Has official SDKsplan not known

Alternatives

The same job

These do what Caffeine does.

  1. Guava Google core libraries for Java

Compare Caffeine with the top 3