Revise documentation for cache infrastructure setup

Closes gh-28250
This commit is contained in:
Juergen Hoeller
2023-08-21 15:42:50 +02:00
parent d0d0ed0578
commit 8be77cc650
3 changed files with 22 additions and 11 deletions

View File

@@ -424,10 +424,13 @@ Placing this annotation on the class does not turn on any caching operation.
An operation-level customization always overrides a customization set on `@CacheConfig`.
Therefore, this gives three levels of customizations for each cache operation:
* Globally configured, available for `CacheManager`, `KeyGenerator`.
* Globally configured, e.g. through `CachingConfigurer`: see next section.
* At the class level, using `@CacheConfig`.
* At the operation level.
NOTE: Provider-specific settings are typically available on the `CacheManager` bean,
e.g. on `CaffeineCacheManager`. These are effectively also global.
[[cache-annotation-enable]]
== Enabling Caching Annotations
@@ -446,6 +449,13 @@ To enable caching annotations add the annotation `@EnableCaching` to one of your
@Configuration
@EnableCaching
public class AppConfig {
@Bean
CacheManager cacheManager() {
CaffeineCacheManager cacheManager = new CaffeineCacheManager();
cacheManager.setCacheSpecification(...);
return cacheManager;
}
}
----
@@ -460,7 +470,11 @@ Alternatively, for XML configuration you can use the `cache:annotation-driven` e
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache https://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven/>
<cache:annotation-driven/>
<bean id="cacheManager" class="org.springframework.cache.caffeine.CaffeineCacheManager">
<property name="cacheSpecification" value="..."/>
</bean>
</beans>
----