From fa247a16c15164b55e3a485c09c1a111775ab36e Mon Sep 17 00:00:00 2001 From: Rikako Wu <496063163@qq.com> Date: Wed, 8 Mar 2023 15:58:36 +0800 Subject: [PATCH] =?UTF-8?q?spring=20cache=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spring/spring cache/spring cache.md | 7 +++++++ 1 file changed, 7 insertions(+) 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