-
Notifications
You must be signed in to change notification settings - Fork 38.5k
WebClient request sent twice instantly when using @Cacheable #32370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was able to reproduce this and will have a look at how we can improve puts in reactive caching support. |
@snicoll @simonbasle |
The fix is done and additionally handles cases where the initial subscriber to the cacheable |
thinking about it a bit more, I'm not satisfied with the above change. from a user perspective, this makes the caching a bit too nondeterministic... the number of elements cached would now actually depend not only on the operators used in the with the example previously used ( I'll revert my change to get back to the previous behavior (exhausting the original |
Hi all,
We started using the spring cache abstraction in our REST API. The methods we want to cache make an HTTP request to a third-party API using WebClient.
The issue occurs when the @Cacheable method returns a Flux, we can see in the logs that the HTTP request is submitted twice instantly. This does not happen when the method returns a Mono.
I was hoping to gain some understanding as to why this double call occurs and how to avoid this from happening?
Thanks for your input.
Using spring-boot 3.2.3, spring-webflux.
Here is a small project showing the issue: https://github.com/dor3no/cacheable-double-request
The text was updated successfully, but these errors were encountered: