Lukas Krecan opened SPR-12967 and commented

It would be nice to support caching of ListenableFuture (CompletableFuture) results. Imagine that your method returns ListenableFuture and you want to cache the result (not the future itself). If I am not mistaken it is not currently supported.

I may send you a pull request, but I'd like to hear if it makes sense. It may be a bit confusing since the cache would be filled/evicted not upon the method exit but upon the future completion.


Affects: 4.1.6

Comment From: spring-projects-issues

Lukas Krecan commented

Hint of the solution https://github.com/lukas-krecan/spring-framework/commit/48329ff9026cbb0c419aaed0a40b171c2d03530a

Comment From: spring-projects-issues

Stéphane Nicoll commented

We don't foresee such feature in the 4.x line as it sounds it's part of a more general reactive effort.

Looking at your proposal it has significant impacts on the boundaries and the semantics of the caching aspect (basically what happens when we exit the method vs. what happens when the value to cache is actually made available). JSR-107 has also some plans to add an asynchronous API (see this issue) so this request may benefit from that stuff.

Comment From: spring-projects-issues

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Comment From: jhoeller

As explained in #17920 (specifically https://github.com/spring-projects/spring-framework/issues/17920#issuecomment-1646004504), we have a CompletableFuture based arrangement with the Caffeine AsyncCache as a primary provider now. That effort comes with equivalent reactive support but can be used standalone with just CompletableFuture as well, effectively addressing this ticket here too.