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

Mono.cache should clarify concurrency guarantees #2782

Closed
jzheaux opened this issue Sep 21, 2021 · 0 comments · Fixed by #2790
Closed

Mono.cache should clarify concurrency guarantees #2782

jzheaux opened this issue Sep 21, 2021 · 0 comments · Fixed by #2790
Assignees
Labels
type/documentation A documentation update
Milestone

Comments

@jzheaux
Copy link

jzheaux commented Sep 21, 2021

Documentation Issue

Recently, I was using Mono.cache() and thought that it did not provide concurrency guarantees.

That is, I understood that once the result is computed, it would not be re-computed. But, I wondered what would happen before the result was cached. Would two concurrent subscriptions result in two separate computations?

Improvement Suggestion

@simonbasle explained to me that Mono.cache() does indeed ensure that concurrent subscriptions will not result in multiple computations:

it will prevent concurrent subscriptions from triggering 2 upstream subscriptions to the source, ie prevent double computation if the source only computes in response to a subscription (which it should)

I think something similar to @simonbasle's explanation would be a nice addition to Mono.cache()'s JavaDoc.

@reactorbot reactorbot added the ❓need-triage This issue needs triage, hasn't been looked at by a team member yet label Sep 21, 2021
@simonbasle simonbasle added type/documentation A documentation update and removed ❓need-triage This issue needs triage, hasn't been looked at by a team member yet labels Sep 24, 2021
@simonbasle simonbasle added this to the 3.4.11 milestone Sep 24, 2021
simonbasle added a commit that referenced this issue Sep 24, 2021
This commit polishes the javadoc of most cache variants in Mono:
 - explicit the behavior in case of concurrent subscriptions for
 `cache()`, `cache(Duration)` and `cache(Function)`
 - polish (un)ordered lists and paragraph breaks in `cacheInvalidateIf`
 and `cacheInvalidateWhen` javadoc.

Fixes #2782.
@simonbasle simonbasle self-assigned this Sep 24, 2021
simonbasle added a commit that referenced this issue Sep 24, 2021
This commit polishes the javadoc of most cache variants in Mono:
 - explicit the behavior in case of concurrent subscriptions for
 `cache()`, `cache(Duration)` and `cache(Function)`
 - polish (un)ordered lists and paragraph breaks in `cacheInvalidateIf`
 and `cacheInvalidateWhen` javadoc.

Fixes #2782.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/documentation A documentation update
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants