From 0e6abd1377f50a6b4e43392c6b634eb273048868 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 14 Aug 2023 11:58:05 +0200 Subject: [PATCH] Provide more information about using spring.cache.type=none Closes gh-33694 --- .../spring-boot-docs/src/docs/asciidoc/io/caching.adoc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/caching.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/caching.adoc index e7dbab184c..b6e19c11c1 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/caching.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/caching.adoc @@ -49,8 +49,8 @@ If you have not defined a bean of type `CacheManager` or a `CacheResolver` named Additionally, {spring-boot-for-apache-geode}[Spring Boot for Apache Geode] provides {spring-boot-for-apache-geode-docs}#geode-caching-provider[auto-configuration for using Apache Geode as a cache provider]. -TIP: It is also possible to _force_ a particular cache provider by setting the configprop:spring.cache.type[] property. -Use this property if you need to <> in certain environments (such as tests). +TIP: If the `CacheManager` is auto-configured by Spring Boot, it is possible to _force_ a particular cache provider by setting the configprop:spring.cache.type[] property. +Use this property if you need to <> in certain environments (such as tests). TIP: Use the `spring-boot-starter-cache` "`Starter`" to quickly add basic caching dependencies. The starter brings in `spring-context-support`. @@ -269,7 +269,10 @@ This is similar to the way the "real" cache providers behave if you use an undec [[io.caching.provider.none]] ==== None When `@EnableCaching` is present in your configuration, a suitable cache configuration is expected as well. -If you need to disable caching altogether in certain environments, force the cache type to `none` to use a no-op implementation, as shown in the following example: +If you have a custom `CacheManager`, consider defining it in a separate `@Configuration` class so that you can override it if necessary. +None uses a no-op implementation that is useful in tests, and slice tests use that by default via `@AutoConfigureCache`. + +If you need to use a no-op cache rather than the auto-configured cache manager in a certain environment, set the cache type to `none`, as shown in the following example: [source,yaml,indent=0,subs="verbatim",configprops,configblocks] ----