Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add *Update methods to update an existing tag (#24)
This is useful to avoid a double lookup: once to find the current value, the second time to update its value. The tag could be a counter we want to update or, with the generics tree, any struct/map. `SetOrUpdate()` is the same as `Set()`, but when there already is a tag, it is passed to the provided update function instead of being replaced by the provided tag value. If no match, the provided tag value is used instead. `AddOrUpdate()` is the same as `Add()` and works like `Set()` except it will append a tag (when no match) or modify the first matching tag (when there is a match). Both functions take a tag value which is used when the existing tag does not exist (no tag for `SetOrUpdate()` or no matching tag for `AddOrUpdate()`). Both functions take an update function which is used when there is an existing tag and the update function is applied on the existing tag to get another tag. The provided tag is therefore ignored in this case.
- Loading branch information