1. Spring local cache 【Spring 本地缓存】
Spring provided cacheable annotation since 3.1. It's very super convinient to use and can obviously boost application performance.
从3.1版本开始,Spring提供了cacheable注解。它使用起来非常方便,还可以很明显的提升应用性能。具体的,怎么使用呢?
First, create a cache bean.
首先,创建缓存bean。这里,我们设置一个三秒的本地缓存(写后3秒过期)。
@Bean
public Cache ephemeralCache() {
return new ConcurrentMapCache(EPHEMERAL_CACHE, CacheBuilder.newBuilder()
.expireAfterWrite(3, TimeUnit.SECONDS)
.build().asMap(), false);
}
延伸阅读
学习是年轻人改变自己的最好方式
