0

I am trying to implement something like this Spring boot populating cache used by findById method with findAll method

but with R2DBC. However, it does not appear to work as I am returning a Mono.

@Cacheable("stores",key = "#storeId")
Mono<Store> findById(int storeId);

The way I determine it is looking at the general_log of the database and find that it's still performing the query

Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265

1 Answers1

0

I'm not familiar with there being any fluent integration between the @Cacheable annotation and reactive frameworks. The primary issue is that there are no non-blocking cache implementations (JSR-107 cache API is blocking). Only Redis is providing a reactive driver. See Spring.io's reactive caching guide. I've read somewhere that you can still use the annotation on service methods, but that will "only" cache your wrapper objects, i.e., Mono / Flux, but not the actual result of your findById..