feat: add value iterator - #475
Conversation
|
@mangalaman93 Please do let me know if this PR is sufficient for merged based on your earlier comment here #460 (review). I'm assuming based on the CLAssistant, @ilyatotl will need to sign the CLA, if not I might have to squash his commits. |
|
@SkArchon While I can appreciate the usefulness of a first class iterator, I'm worried about the increase in overall memory usage this PR will introduce. 16 bytes for the Could you not roll-your-own by embedding a Cache inside your own struct? Implement |
|
Hi @matthewmcneely, I am happy to remove the For context, we want to repopulate the ristretto cache upon restarts of our router (from the previous instance of the ristretto cache), so with evictions and such using the actual ristretto cache makes sense since it will be the source of truth. But on top of this we would also prefer to not do this if possible by having another map and lock on it for Set and Get wrappers since its on the hot path. |
|
@SkArchon Happy to review a version without the addition of an Item field. |
21be33a to
5112a10
Compare
|
@matthewmcneely I have updated the PR to have iterations only on values, please do let me know if there are any changes to be made, I also squashed the commit history due to the original author being inactive to accept the CLA. |
matthewmcneely
left a comment
There was a problem hiding this comment.
Looking better, thanks!
|
Also do let me know if you would like me to mark the conversations as resolved, or to wait for you the reviewer to mark it as resolved. |
|
Hi @matthewmcneely, I see that you have resolved your previous review comments, please do let me know what else is needed to get this merged. |
|
@SkArchon Can you rebase your fork? I cannot resolve conflicts on forks. |
f52c09a to
fb3ddb3
Compare
|
Because of the merge commit I found it easier to squash. Anyway the merge-base is the tip of the main branch now. |
|
@matthewmcneely Quick question, would it be possible to have a ristretto release (so this would be included), I see the last release in August 2025. |
|
@SkArchon We released v2.4.0 yesterday. Thanks for your contributions. |
…ent-hq#21) This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [github.com/dgraph-io/ristretto](https://github.com/dgraph-io/ristretto) | `v0.2.0` → `v2.4.0` |  |  | --- >⚠️ **Warning** > > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>dgraph-io/ristretto (github.com/dgraph-io/ristretto)</summary> ### [`v2.4.0`](https://github.com/dgraph-io/ristretto/blob/HEAD/CHANGELOG.md#v240---2026-01-21) [Compare Source](dgraph-io/ristretto@v2.3.0...v2.4.0) ##### Added - Implement public `Cache.IterValues()` method ([#​475](dgraph-io/ristretto#475)) - Allow custom key types with underlying types in Key constraint ([#​478](dgraph-io/ristretto#478)) ##### Fixed - Fix compilation on 32-bit archs ([#​465](dgraph-io/ristretto#465)) **Full Changelog**: <dgraph-io/ristretto@v2.3.0...v2.4.0> ### [`v2.3.0`](https://github.com/dgraph-io/ristretto/blob/HEAD/CHANGELOG.md#v240---2026-01-21) [Compare Source](dgraph-io/ristretto@v2.2.0...v2.3.0) ##### Added - Implement public `Cache.IterValues()` method ([#​475](dgraph-io/ristretto#475)) - Allow custom key types with underlying types in Key constraint ([#​478](dgraph-io/ristretto#478)) ##### Fixed - Fix compilation on 32-bit archs ([#​465](dgraph-io/ristretto#465)) **Full Changelog**: <dgraph-io/ristretto@v2.3.0...v2.4.0> ### [`v2.2.0`](https://github.com/dgraph-io/ristretto/blob/HEAD/CHANGELOG.md#v230---2025-08-19) [Compare Source](dgraph-io/ristretto@v2.1.0...v2.2.0) ##### Added - Add public `Cache.RemainingCost()` method ([#​448](dgraph-io/ristretto#448)) - Add support for uint keys ([#​463](dgraph-io/ristretto#463)) ##### Fixed - Fix typo: ffor → for ([#​456](dgraph-io/ristretto#456)) - Correct grammar in error message ([#​461](dgraph-io/ristretto#461)) **Full Changelog**: <dgraph-io/ristretto@v2.2.0...v2.3.0> ### [`v2.1.0`](https://github.com/dgraph-io/ristretto/blob/HEAD/CHANGELOG.md#v220---2025-03-30) [Compare Source](dgraph-io/ristretto@v2.0.1...v2.1.0) ##### Changed - Remove dependency: github.com/pkg/errors ([#​443](dgraph-io/ristretto#443)) ##### Fixed - Switch from using a sync.WaitGroup to closing a channel of struct{} ([#​442](dgraph-io/ristretto#442)) **Full Changelog**: <dgraph-io/ristretto@v2.1.0...v2.2.0> ### [`v2.0.1`](https://github.com/dgraph-io/ristretto/blob/HEAD/CHANGELOG.md#v210---2025-01-09) [Compare Source](dgraph-io/ristretto@v2.0.0...v2.0.1) ##### Added - Add `ShouldUpdate()` function in config ([#​427](dgraph-io/ristretto#427)) ##### Fixed - Fix memory leak while cleaning up expiration map ([#​429](dgraph-io/ristretto#429)) - Execute `m.Unlock` in defer in store.go ([#​425](dgraph-io/ristretto#425)) **Full Changelog**: <dgraph-io/ristretto@v2.0.1...v2.1.0> ### [`v2.0.0`](https://github.com/dgraph-io/ristretto/blob/HEAD/CHANGELOG.md#v201---2024-12-11) [Compare Source](dgraph-io/ristretto@v1.0.1...v2.0.0) **Fixed** - Wait for goroutines to finish ([#​423](dgraph-io/ristretto#423)) - Bump golang.org/x/sys from 0.27.0 to 0.28.0 in the minor group ([#​421](dgraph-io/ristretto#421)) - Bump github.com/stretchr/testify from 1.9.0 to 1.10.0 in the minor group ([#​420](dgraph-io/ristretto#420)) - Bump golang.org/x/sys from 0.26.0 to 0.27.0 in the minor group ([#​419](dgraph-io/ristretto#419)) **Full Changelog**: <dgraph-io/ristretto@v2.0.0...v2.0.1> ### [`v1.0.1`](https://github.com/dgraph-io/ristretto/blob/HEAD/CHANGELOG.md#v101) [Compare Source](dgraph-io/ristretto@v1.0.0...v1.0.1) **This release is deprecated** ### [`v1.0.0`](https://github.com/dgraph-io/ristretto/blob/HEAD/CHANGELOG.md#v100) [Compare Source](dgraph-io/ristretto@v0.2.0...v1.0.0) **This release is deprecated** </details> --- ### Configuration 📅 **Schedule**: Branch creation - "every 2 weeks on monday" (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4wLjYiLCJ1cGRhdGVkSW5WZXIiOiI0My40LjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=--> Co-authored-by: pat-s <patrick.schratz@gmail.com> Reviewed-on: https://codefloe.com/pat-s/dendrite/pulls/21 Co-authored-by: renovate-bot <renovate@codefloe.com> Co-committed-by: renovate-bot <renovate@codefloe.com>
Description
This PR is based off of the PR here #460, I have opened a new PR as this only contains a subset of the changes, and I do not have access to push to the original authors fork.
This PR only contains the iteration function, which iterates on values.
cc: @ilyatotl, @mangalaman93
Checklist