A Spring Boot 4.1.1 module whose test suite is the evidence for the article: 20 tests producing 22 transcripts under docs/output/, plus 12 documentation chapters. Findings the build pins: - @EnableCaching has no exposeProxy attribute; the widely-copied @EnableCaching(exposeProxy = true) does not compile. - Two methods sharing a cache name and an argument type share a key space, and one silently serves the other's answers. - The documented cache-provider detection order does not match CacheType's enum order in 4.1.1: COUCHBASE before INFINISPAN, and CACHE2K before CAFFEINE. - beforeInvocation = true is NOT deferred by TransactionAwareCacheManagerProxy on 7.0.9 - doEvict picks evictIfPresent, which the decorator does not intercept. - Four of five invalid declarations start a clean context and throw at the first call. - Caffeine on the classpath silently displaces the simple provider.
34 lines
1.3 KiB
Plaintext
34 lines
1.3 KiB
Plaintext
# Nothing in application.yml selects a provider. Something still chose one.
|
|
|
|
spring.cache.type : (not set)
|
|
resolved CacheManager bean : org.springframework.cache.caffeine.CaffeineCacheManager
|
|
|
|
Caffeine is on this module's classpath because a later chapter needs TTL and
|
|
size bounds. That single dependency moved every cache in the application off
|
|
the ConcurrentHashMap-backed 'simple' provider.
|
|
|
|
--- the detection order, read out of the enum rather than the documentation ---
|
|
1 GENERIC
|
|
2 JCACHE
|
|
3 HAZELCAST
|
|
4 COUCHBASE
|
|
5 INFINISPAN
|
|
6 REDIS
|
|
7 CACHE2K
|
|
8 CAFFEINE
|
|
9 SIMPLE
|
|
10 NONE
|
|
|
|
CacheConfigurations maps CacheType -> configuration class in an EnumMap, so
|
|
the configurations are imported in this declaration order and the first one
|
|
whose @ConditionalOnClass matches registers the CacheManager. The rest back
|
|
off on @ConditionalOnMissingBean.
|
|
|
|
Spring Boot's reference documentation lists this order as Generic, JCache,
|
|
Hazelcast, Infinispan, Couchbase, Redis, Caffeine, Cache2k, Simple. On
|
|
4.1.1 the enum disagrees in two places: COUCHBASE comes before INFINISPAN,
|
|
and CACHE2K comes before CAFFEINE. The second one is the one that can bite:
|
|
with both on the classpath you get Cache2k, not Caffeine.
|
|
|
|
Nothing logs the decision at INFO. Set spring.cache.type explicitly.
|