You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
…bsent cache mapping.
We now use ValueWrapper to differentiate in the async API between cache misses and cached null values.
Closes: #2783
Original Pull Request: #2785
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 bynull
as aCompletableFuture
value - andnull
as a cached value, effectively treating a cached null value as a cache miss. You may address this through theretrieve(key)
implementation returning aCompletableFuture
with aValueWrapper
that holds the nullable value. Since you derive fromAbstractValueAdaptingCache
anyway, you could simply calltoValueWrapper(value)
before passing it into theCompletableFuture
.Note that technically just actual
null
values have to be wrapped in aValueWrapper
while regular values may be exposed directly as aCompletableFuture
value. InCaffeineCacheManager
, we consistently exposeValueWrapper
in case ofallowNullValues=true
, while we rather expose the regular values in case ofallowNullValues=false
(where we can expose the Caffeine-providedCompletableFuture
directly without post-processing then). The common cache infrastructure can deal with any variant of the cache implementation here, soRedisCache
may choose whatever makes sense for it - as long as actualnull
values are wrapped as a minimum.The text was updated successfully, but these errors were encountered: