guava 如何快速切換到 caffeine

在這裏插入圖片描述

前言

首先看一個spring官方的issue,https://github.com/spring-projects/spring-framework/issues/18370

Caffeine intends to supersede the caching support in the Google Guava library with an actively maintained Java 8+ version in standalone form.
We’re going to introduce first-class Caffeine support in Spring 4.3 and should consider dropping our then-outdated Guava caching support in Spring 5.0.

大概意思就是spring4.3開始支持caffeine(咖啡因),spring 5.0 也就是springboot 2.0 ,放棄對guava cache的支持。

如何快速切換

我們項目中,可能用的guava cache比較多,官方也給了適配器,讓我們去迅速切換。

官方鏈接: https://github.com/ben-manes/caffeine

gradle

compile 'com.github.ben-manes.caffeine:guava:2.8.4'

maven

<dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>guava</artifactId>
 </dependency>
  • 結合前面博客中兩級緩存的例子,坐下迅速切換,上圖

在這裏插入圖片描述

參考鏈接

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章