caffeine
3.1.8
咖啡因是高性能,接近最佳的缓存库。有关更多详细信息,请参见我们的用户指南,并浏览API文档以获取最新版本。
咖啡因使用Google Guava Inspired API提供了内存中的缓存。这些改进取决于我们设计Guava的高速缓存和ConcurrentLinkedHashmap的经验。
LoadingCache < Key , Graph > graphs = Caffeine . newBuilder ()
. maximumSize ( 10_000 )
. expireAfterWrite ( Duration . ofMinutes ( 5 ))
. refreshAfterWrite ( Duration . ofMinutes ( 1 ))
. build ( key -> createExpensiveGraph ( key ));
咖啡因提供灵活的结构,以创建具有以下可选功能组合的高速缓存:
此外,咖啡因提供以下扩展:
在社区中使用咖啡因提供了整合:
在您附近为基础设施提供动力:
从Maven Central下载或通过Gradle下载:
implementation( " com.github.ben-manes.caffeine:caffeine:3.1.8 " )
// Optional extensions
implementation( " com.github.ben-manes.caffeine:guava:3.1.8 " )
implementation( " com.github.ben-manes.caffeine:jcache:3.1.8 " )
对于Java 11或更高,请使用3.x
,否则使用2.x
有关更改的详细信息,请参见发行说明。
开发版本的快照可在Sonatype的快照存储库中获得。