-
-
Notifications
You must be signed in to change notification settings - Fork 76
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 the "entry" and "entry_by_ref" APIs #193
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add `Entry` struct with the following methods: - `is_fresh` - `key` - `value` - `into_value` - Add `OwnedKeyEntrySelector` and `RefKeyEntrySelector` structs to `sync` and `future` modules. They provide the following methods for now: - `or_default` - `or_insert` - `or_insert_with` - `or_insert_with_if` - Add `entry` and `entry_by_ref` methods to `sync` and `future` caches that return `OwnedKeyEntrySelector` and `RefKeyEntrySelector` respectively. - Deprecate `get_with_if` methods in `sync` and `future` caches.
8a78854
to
ce1c1e2
Compare
Add `or_optionally_insert_with` method to `OwnedKeyEntrySelector` and `RefKeyEntrySelector` structs of `sync` and `future` modules.
Add `or_try_insert_with` method to `OwnedKeyEntrySelector` and `RefKeyEntrySelector` structs of `sync` and `future` modules.
Write some documentation for the `OwnedKeyEntrySelector` and `RefKeyEntrySelector` structs.
Conflicts: src/future/cache.rs src/sync/cache.rs src/sync/segment.rs src/sync_base/base_cache.rs
Follow up the previous git merge.
Update the test cases for the entry APIs.
tatsuya6502
commented
Nov 6, 2022
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.
Left some comments.
Cosmetic changes on the doc, a function signature and variable names.
tatsuya6502
commented
Nov 7, 2022
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.
Merging.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
entry
andentry_by_ref
APIs tosync
andfuture
caches. They return a structOwnedKeyEntrySelector
orRefKeyEntrySelector
respectively. You can use their methods likeor_insert
to select or insert an entry of a cache.These methods on the entry selectors return an
Entry
, a snapshot of key and value, carrying additional informationis_fresh
to indicates if the value was freshly computed or cached.OwnedKeyEntrySelector
andRefKeyEntrySelector
structs provide the following methods:or_default
or_insert
or_insert_with
or_insert_with_if
or_optionally_insert_with
or_try_insert_with
Also deprecate
get_with_if
methods insync
andfuture
caches. The same functionality is provided by the entry selector'sor_insert_with_if
method.