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的快照存儲庫中獲得。