Description
Following up on spring-projects/spring-framework#31637, the core caching infrastructure is able to handle the current RedisCache.retrieve(key)
implementation now, making Spring Framework 6.1.1 compatible with the latest Spring Data Redis.
However, there is one remaining concern: RedisCache
has support for nullable cache values but currently does not differentiate between a late-determined cache miss - indicated by null
as a CompletableFuture
value - and null
as a cached value, effectively treating a cached null value as a cache miss. You may address this through the retrieve(key)
implementation returning a CompletableFuture
with a ValueWrapper
that holds the nullable value. Since you derive from AbstractValueAdaptingCache
anyway, you could simply call toValueWrapper(value)
before passing it into the CompletableFuture
.
Note that technically just actual null
values have to be wrapped in a ValueWrapper
while regular values may be exposed directly as a CompletableFuture
value. In CaffeineCacheManager
, we consistently expose ValueWrapper
in case of allowNullValues=true
, while we rather expose the regular values in case of allowNullValues=false
(where we can expose the Caffeine-provided CompletableFuture
directly without post-processing then). The common cache infrastructure can deal with any variant of the cache implementation here, so RedisCache
may choose whatever makes sense for it - as long as actual null
values are wrapped as a minimum.