spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.19k stars 37.96k forks source link

Spring Cache support for Async Caffeine #26713

Closed namila007 closed 3 years ago

namila007 commented 3 years ago

Hi,

I'm currently using Caffeine with Spring Caffeine cache support implementation. I want to know is there any support for Async LoadingCache support on the spring cache? or if I want async caching do I want to move out with AsyncLoadingCache without spring caffeine cache support;? PS: I'm using spring-webflux

snicoll commented 3 years ago

Support for LoadingCache has been discussed several times in the past, see for instance #25173. Reactive types are not yet supported, see #17920. If you are using the annotation model, loading cache does not make much sense. If you are using the Cache API directly, the contract is blocking at the moment so not a great fit for a reactive app.

Going forward, please ask questions on StackOverflow, as mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements.

ben-manes commented 3 years ago

@snicoll fyi in case you weren't familiar or forgot, given everything you work on, Caffeine also offers an AsyncCache interface for reactive applications. This stores and returns CompletableFuture values, which Reactor can convert between easily enough. In these cases when users should use the native apis directly, that interface is the best fit.

snicoll commented 3 years ago

@ben-manes thanks for following up. I am aware, but the question above was about the Spring Cache abstraction, and so was my answer.