-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: built-in map: add delete hook func And set hook func #60311
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
Comments
Most of these functions already exist in the upcoming 1.21 release. Can you trim this back to exactly what you are proposing? It would also help to point to some existing code that could use these new functions. Thanks. |
the proposal: offer hook to stuff that cares about oldkvpairs when exec map operation
orginially ,we must write some code like this:
In any cases which care about prev kvpairs, when we do some operation,such as set,delete.
|
To be clear, adding this to the maps package won't be any more efficient than doing it yourself. So this doesn't have to be in the standard library. Can you point to existing code that would benefit from these functions? If possible, don't just describe it, actually show us the existing repository. Thanks. Also, see #41130. |
Yeah,I‘m confused with the builtin map.This may be built-in,not in maps package.
code:
|
I think we ruled out having a builtin in #41130, as discussed there. We would only reconsider that decision if there is new information. |
We can find similar api in other languages:
In actually, this can be |
I'm sorry, I don't see any new information here that would lead us to reconsider the decision made in #41130. Closing. Please comment if you disagree. |
#47649
some cases:
eg:
when cache evited some item, delete key from map want to do some op: only kvpairs exists,
set a kvpairs, we want to get the old kvpairs to eslimate cost,and using the new cost - the old cost
The text was updated successfully, but these errors were encountered: