ReactiveRedisTemplate Cache Miss

639 views Asked by At

How do we handle cache miss scenario using ReactiveRedisTemplate<String, String>? Also, need to log and treat any error from underlying Redis cache as cache miss.

please suggest.

1

There are 1 answers

1
wayatheroad On BEST ANSWER

It's hard to say without a code example, but you can utilize the operator .switchIfEmpty(). You'll need to defer the Mono so it's lazy loaded and only evaluated after the Redis template returns something.

.switchIfEmpty(Mono.defer(() -> callMethodToFetchData());