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

Add SetIfAbsent(), returning a value indicating whether the key already existed #39

Open
anorth opened this issue Nov 23, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@anorth
Copy link
Member

anorth commented Nov 23, 2020

The Set method is implemented as blind upsert and does not return any indication of what value, if any, previously existed for the key in question. Callers that wish to leave any existing value intact, or save or report it elsewhere after it is overwritten, must first perform a Get or Has in order to establish if one exists. Set could instead return an indication of whether the key previously existed.

See discussion about this for the HAMT in filecoin-project/go-hamt-ipld#75.

@anorth anorth added the enhancement New feature or request label Nov 23, 2020
@anorth anorth changed the title Set() to return a value indicating whether the key already existed Add SetIfAbsent(), returning a value indicating whether the key already existed Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant