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
这是什么?Caffeine 是一个面向 Java 的高性能、接近最优的内存缓存库,其 API 受 Guava 启发。
这是进程内缓存,还是像 Redis 那样的独立缓存服务器?它纯粹是一个进程内的内存缓存,嵌入在你的 Java 应用中,而不是像 Redis 或 Memcached 那样的独立服务器。
我该如何把它添加到项目中?从 Maven Central 拉取 caffeine 构件,或将其添加为 Gradle 依赖。
我需要哪个 Java 版本?如果你使用 Java 11 或更高版本,请使用 3.x 版本;如果是较旧的 Java 版本,请继续使用 2.x。
Caffeine 能处理多台服务器之间的缓存吗?不能,它是单 JVM 内存缓存;如需分布式缓存,可以将它与 Infinispan 等数据网格搭配使用,列出的若干集成已经这样做了。
我必须已经在使用 Guava 才能从中受益吗?不必。Caffeine 的 API 只是受 Guava 缓存启发,但它是独立的,并且还提供 Guava 适配器,以兼容现有的基于 Guava 的代码。
Caffeine 使用什么淘汰策略?它使用一种基于 TinyLFU(Tiny Least Frequently Used,微型最少频率使用)的自适应、接近最优的淘汰策略,相关研究论文由项目创建者共同撰写。
哪些框架提供了 Caffeine 集成?已有社区集成支持 Spring Cache、Play Framework、Micronaut、Quarkus、Camel 和 JHipster,另有 Kotlin 封装(Aedile、Kotlin Coroutines)以及 Scala 的 Scaffeine 封装。
哪些项目在生产环境中使用 Caffeine?它为 Cassandra、HBase、Solr、Kafka、Infinispan、Dropwizard、Accumulo、Corfu、Neo4j 和 Druid 等项目内部的缓存层提供支持。
Caffeine 能统计缓存使用情况吗?可以,它能够累计缓存访问统计数据,如命中率和未命中率,便于监控缓存效果。
Creator
ben-manes
Size
114.9 MB
Stars
17.9K
Age
11y
Commits · 90 Days