Pablo D铆az-L贸pez opened SPR-14235 and commented
Currently when using cache annotations on beans it caches the Observables like other types, So it will not cache its value.
I tried to use the following pattern to handle it:
@Cacheable("items")
public Observable<Item> getItem(Long id) {
return Observable.just(id)
.map(myrepo::getById)
.cache();
}
In the happy path, as we cache the Observable values works pretty well, but if getById throws an exception the observable is cached with the exception which isn't how it should work.
It would be also very nice to have support to Single.
If you give me some advice I can try to do a PR to solve this.
Affects: 4.2.5
Sub-tasks:
Referenced from: pull request https://github.com/spring-projects/spring-framework/pull/1066
1 votes, 8 watchers
Hi, what is the status of this ? If I understand well, there was discussion about a ReactiveCache since JSR-107 is a blocking API. Has something evolved since the opening of this issue ?
Nothing has been evolving in that area I am afraid and given the lack of proprietary implementations, I think cache vendors themselves aren't keen to explore that route either. This leaves us with the blocking model which isn't a great fit with whatever @Cacheable has to offer.
There is a cache operator in reactor though and I remember so initial work trying to harmonize this here. Perhaps @simonbasle can refresh my memory?
I made an attempt at an opinionated API towards caching in reactor-extra (see reactor-addons repo), but that has not seen much focus nor feedback since then, so I wouldn't claim it is perfect.
Are there any updates on this?
No, the latest update on is here. Most cache libraries (including JCache) are still on a blocking model so my comment above still stands.
Most helpful comment
Are there any updates on this?