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

Only one call to fetch should return :commit #290

Closed
whitfin opened this issue Jul 9, 2022 · 0 comments · Fixed by #295
Closed

Only one call to fetch should return :commit #290

whitfin opened this issue Jul 9, 2022 · 0 comments · Fixed by #295
Assignees
Milestone

Comments

@whitfin
Copy link
Owner

whitfin commented Jul 9, 2022

References comments in #288 (comment). If you call the following 10 times, and my_func/1 takes a sufficient amount of time, "hello" will be printed 10 times.

with {:commit, _} = Cachex.fetch(cache, key, &my_func/1) do
  IO.puts("hello")
end

Realistically, only the first call to fetch should return the :commit tag and any queued listeners should return :ok so that it only occurs once with this pattern.

I'm going to label this an enhancement because it was never explicitly stated how this should work, but realistically I think this is probably a bug and should be corrected ASAP.

@whitfin whitfin added this to the v3.5.0 milestone Jul 9, 2022
@whitfin whitfin self-assigned this Jul 9, 2022
@whitfin whitfin changed the title Only one call to fetch should return :ok Only one call to fetch should return :commit Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant