一、首先导入依赖
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.6-jre</version>
</dependency>
二、guava的配置,那个24指的是24小时,即缓存在最近写或者access后24小时才失效,时间单位在config配置文件中配置
guava.cache.config.maximum-size=1024
guava.cache.config.expire-after-access-duration=24
三、配置的properties类
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "guava.cache.config")
public class GuavaProperties {
private long maximumSize;
private long maximumWeight;
private long expireAfterWriteDuration;
private long expireAfterAccessDuration;
private long refreshDuration;
privat