配置缓存注解版
- 启动类上添加@EnableCaching、
- 具体方法上@Cacheable(value = “menuCache”),key是底层创建的
- 为了防止查询数据出现脏读,在关于查询数据的删除数据方法上添加@CacheEvict(value = “menuCache”,allEntries = true)
从CacheManager接口中查找
public interface CacheManager {
@Nullable
Cache getCache(String var1);
Collection<String> getCacheNames();
}
然后找到实现类
private final ConcurrentMap<String, Cache> cacheMap = new ConcurrentHashMap(16);中的String就是之前的用户自定义注解value
public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderAware {
private final ConcurrentMap<String, Cache> cacheMap = new ConcurrentHashMap(16);
private boolean dynamic = true;
pr