refactor(cache): add GetWithTeamID method to SnapshotCache#2587
refactor(cache): add GetWithTeamID method to SnapshotCache#2587AdaAibaby wants to merge 3 commits intoe2b-dev:mainfrom
Conversation
- Add new SQL query GetLastSnapshotByTeam with teamID filtering - Implement GetWithTeamID method in SnapshotCache - Use composite cache key (sandboxID:teamID) to avoid collisions - Mark Get method as deprecated - Add unit tests for new functionality - Fixes ENG-3544: scope GetLastSnapshot query by teamID to avoid post-fetch ownership check This is the foundation for subsequent PRs that will update individual handlers (sandbox_get, sandbox_pause, sandbox_resume, sandbox_connect) to use the new GetWithTeamID method, ensuring ownership validation at the database level.
|
We require contributors to sign our Contributor License Agreement, and we don't have @adababys on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
There was a problem hiding this comment.
Code Review
The introduction of a composite cache key in GetWithTeamID breaks the existing Invalidate method, which only deletes the simple sandboxID key, leading to stale snapshot data. The new test file contains a duplicate package declaration that will cause a compilation error.
- Update Invalidate method to delete team-scoped cache keys using DeleteByPrefix - Add InvalidateWithTeamID method for precise cache invalidation - Prevent stale snapshot data from persisting in cache after invalidation - Fixes cache pollution issue identified in code review The composite cache key (sandboxID:teamID) introduced in the previous commit required updating the invalidation logic to ensure all related cache entries are properly cleared, not just the simple sandboxID key. This fix ensures: 1. Invalidate(sandboxID) deletes both simple key and all team-scoped keys 2. InvalidateWithTeamID(sandboxID, teamID) deletes only the specific team's key 3. No stale snapshot data persists after invalidation
|
We require contributors to sign our Contributor License Agreement, and we don't have @adababys on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
We require contributors to sign our Contributor License Agreement, and we don't have @adababys, @AdaAibaby on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @adababys on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
The cla-bot has been summoned, and re-checked this pull request! |
This is the foundation for subsequent PRs that will update individual handlers (sandbox_get, sandbox_pause, sandbox_resume, sandbox_connect) to use the new GetWithTeamID method, ensuring ownership validation at the database level.