Skip to content
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

Is there a way to cache http response on redis with WebClient #24569

Closed
taylancapraz opened this issue Feb 22, 2020 · 3 comments
Closed

Is there a way to cache http response on redis with WebClient #24569

taylancapraz opened this issue Feb 22, 2020 · 3 comments
Labels
for: stackoverflow A question that's better suited to stackoverflow.com status: invalid An issue that we don't feel is valid

Comments

@taylancapraz
Copy link

taylancapraz commented Feb 22, 2020

Hi

I decided to migrate existing Spring Boot projects to webflux. The Spring Boot version I update to is 2.2.4.RELEASE.

I have many microservices. I was caching http responses using in memory cache, and redis cache. I found a workaround to cache incoming responses in the current state. However, I need to use redis cache in some projects. Up to now, I couldn't find any way to do this.

Is there anyone who use redis cache with webflux? Or do you have any recommendation to do this?

In addition, will there be support for using @Cacheable annotation with webflux. If not, I would ask you to take it into planning.

@taylancapraz taylancapraz changed the title Is there a way to cache http responses on redis with WebClient Is there a way to cache http response on redis with WebClient Feb 22, 2020
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 22, 2020
@bclozel
Copy link
Member

bclozel commented Feb 24, 2020

Hello @taylancapraz

Spring Data Redis supports reactive types, so this should be possible. Now depending on your use case (what should be the keys, what should be stored in Redis and how it should be serialized), the answer to your question may differ greatly.

Could you ask this question on StackOverflow? We're trying to keep the issue tracker for bugs and enhancements only. My only recommendation would be to pay attention to data size (avoid buffering in memory too large amounts of data) and to leverage, if possible, HTTP cache headers like ETags.

Now Spring Framework does not support reactive types with @Cacheable, but we have a dedicated issue for that (that you can subscribe to). The bad news is, right now there are very few cache implementations accepting those, so it's hard for us to design a solution that works for many implementations. See #17920

@bclozel bclozel closed this as completed Feb 24, 2020
@bclozel bclozel added for: stackoverflow A question that's better suited to stackoverflow.com status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 24, 2020
@agisbert
Copy link

Did anyone find any solution to this? We have a setup based on Caffeine, but we were hoping to migrate to Redis...

As far as I know, the solution would go into the direction of modifying/custom implementing the current RedisCacheManager, RedisCacheWriter, and RedisCache, so it would use the reactive Redis template to serialize/deserialize reactive types as if the whole cache thingy was a repository.

Ended up in -> https://jira.spring.io/browse/DATAREDIS-967 and to be honest, I cannot agree with what these guys state as reason. The cache implementations are blocking, not @Cacheable itself...

Does someone know of any persisting cache implementation (like Redis) that would support reactive types?

@snicoll
Copy link
Member

snicoll commented Jul 8, 2020

@agisbert the Spring Data issue you've referenced is pointing to #17920 so please subscribe to that if you're interested in support of @Cacheable with reactive types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stackoverflow A question that's better suited to stackoverflow.com status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants