Polish "Add property to enable Caffeine async cache mode"

Restructured to spring.cache.caffeine.cache-mode with an enum that can
be "native" or "async". Also clarified in the documentation the scope
of the property and that custom caches are not affected.

See gh-51844
This commit is contained in:
Stéphane Nicoll
2026-09-28 10:45:01 +02:00
parent 4e4cdc3fda
commit 0fe97e3da2
4 changed files with 52 additions and 32 deletions
@@ -223,7 +223,10 @@ If a javadoc:com.github.benmanes.caffeine.cache.CacheLoader[] bean is defined, i
Since the javadoc:com.github.benmanes.caffeine.cache.CacheLoader[] is going to be associated with _all_ caches managed by the cache manager, it must be defined as `CacheLoader<Object, Object>`.
The auto-configuration ignores any other generic type.
To expose asynchronous caches backed by Caffeine's javadoc:com.github.benmanes.caffeine.cache.AsyncCache[], adding support for `Cache.retrieve`, set configprop:spring.cache.caffeine.async[] to `true`.
To enable the use of `Cache#retrieve`, an javadoc:com.github.benmanes.caffeine.cache.AsyncCache[] should be available.
Such caches can be created explicitly with a `CacheManagerCustomizer` bean that calls `CaffeineCacheManager#registerCustomCache`.
Alternatively, named caches and caches on demand can be async by setting configprop:spring.cache.caffeine.cache-mode[] to `async`.
Regular, native, caches can still be configured explicitly using a customizer bean.