-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add new api optionally_get_with
#187
Conversation
@tatsuya6502 Feel free to take a look when you have time :) |
1224598
to
a256c42
Compare
Hmm, looks like the failed CI is not related to the new API changes? https://github.com/moka-rs/moka/blob/master/src/common/concurrent/entry_info.rs#L145 |
Thank you very much for the PR. I will review it when I have some spare time. (hopefully tonight, UTC+0800). You are right. The failed CI is not related to this PR, so do not worry about it. It is already failing on the master branch when Rust 1.66 nightly is used. I am trying to fix it by #186. |
Thank you for the suggestion. Please feel free to edit the documentation and submit a PR if you can make it better. That would be great help. I am not a native English speaker and having a bit struggle to write clear, concise and consistent English. https://docs.rs/moka/latest/moka/sync/struct.Cache.html#method.try_get_with
I think the word "even if" is a wrong choice here? It would imply "always". But what the cache actually does is coalescing concurrent queries.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me! Thank you for adding the unit tests and documentation.
FYI, I released v0.9.6 with updated document. I hope it will be more clear about the guarantee. I also found that there are small chances for race conditions in concurrent calls of The Documentation UpdateBeforehttps://docs.rs/moka/0.9.5/moka/sync/struct.Cache.html#method.optionally_get_with
Afterhttps://docs.rs/moka/0.9.6/moka/sync/struct.Cache.html#method.optionally_get_with
|
Hi @tatsuya6502 Thanks for letting me know. The change looks great! |
This is the inital PR for issue #184
I was thinking to use TypeId with
()
type for the Error type when returnInitResult
, but not sure if this will have some conflict with other parts of the code as I saw()
is use somewhere else. So I created internal structureOptionallyNone
to represent this error type.I also noticing the guarantee of call once only if the init closure return
Ok/Some
. If it returnsErr/None
, it is not gurantee to have once call. I think this definitely make sense, perhaps it is good to update the docummentation? ThanksLet me know if there's any comments or suggestions. Thanks