这篇文章,主要介绍Guava Cache本地缓存的常用操作方法。
目录
1.7、RemovalListener缓存移除监听器(同步方式)
1.8、RemovalListener缓存移除监听器(异步方式)
一、Guava Cache本地缓存
Guava是google提供的一个通用工程模块,它提供了很多常用的核心库功能,例如:集合操作Collections、并发编程库、通用注解库、字符串处理的依赖库、I/O操作的库、Cache本地缓存库等等。你可以把guava看作和hutool工具包差不多。
1.1、引入guava依赖
guava是google公司开发的依赖库,在pom文件中添加google的guava依赖。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>