diff --git a/spring/spring cache/spring cache.md b/spring/spring cache/spring cache.md index 03a1c51..977b9d6 100644 --- a/spring/spring cache/spring cache.md +++ b/spring/spring cache/spring cache.md @@ -16,6 +16,7 @@ - [@EnableCaching](#enablecaching) - [配置cache 存储](#配置cache-存储) - [Cache Redis](#cache-redis) + - [限制cache-names](#限制cache-names) # Spring Cache ## Cache Abstract @@ -163,4 +164,10 @@ public class MyRedisCacheManagerConfiguration { } } +``` +### 限制cache-names +默认情况下,cache是在需要时才创建的,但如果想要限制可用的cache-names,可以设置`cache.cache-names`属性。 +在设置`cache.cache-names`属性之后,那么如果运行时应用想要获取cache-names之外的cache,将会在运行时抛出异常。 +```properties +spring.cache.cache-names=cache1,cache2 ``` \ No newline at end of file