GuavaCache基本用法 如果我们需要对从db获取的数据增加本地缓存,缓存10s过期,用guava cache很简单: 初始化一个Cache对象,定义load方法,或者在获取值的时候传一个load方法即可 // 定义cache Cache<String, Object> cache = CacheBuilder.newBuilder().maximumSize(100).expireAfterWrite(10L, TimeUnit.SECONDS).build(