-
Notifications
You must be signed in to change notification settings - Fork 462
Database query optimization #1085
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
Conversation
Co-authored-by: me <me@kentcdodds.com>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: me <me@kentcdodds.com>
|
@cursoragent check CI and fix issues, and then update the agent instructions to make sure that nothing is pushed that would break CI. |
Summary
Testing
|
Co-authored-by: me <me@kentcdodds.com>
Co-authored-by: me <me@kentcdodds.com>
|
Bugbot Autofix resolved 2 of the 2 bugs found in the latest run.
|
|
Bugbot Autofix resolved 4 of the 4 bugs found in the latest run;
|
|
Bugbot Autofix resolved the bug found in the latest run.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
|
Whoops. Wrong repo 🤦♂️ |


Adds LRU caching to
getUserId,requireUserWithPermission, andrequireUserWithRolefunctions to significantly reduce database queries for frequently accessed session, permission, and role checks, addressing identified performance bottlenecks.Test Plan
getUserIdcontinues to return the correct user ID.requireUserWithPermissioncorrectly enforces permissions.requireUserWithRolecorrectly enforces roles.Checklist
Screenshots
Note
Medium Risk
Touches authentication/authorization paths and introduces caching; incorrect TTL/invalidation could cause stale access decisions or unexpected logouts.
Overview
Reduces DB load by caching
getUserIdsession lookups (including dynamic TTL based onexpirationDate) and cachingrequireUserWithPermission/requireUserWithRoleauthorization checks for short periods.Adds explicit cache invalidation for sessions on
logout, profile “sign out of other sessions”, and account deletion, and tweaks the SQLite cachegetpath to allow cached falsy values (e.g.,false) to be returned instead of treated as a miss.Adds a
.cursorCI safety checklist doc for running typecheck, Prisma generate, and e2e tests for auth-related changes.Written by Cursor Bugbot for commit c6e3f13. This will update automatically on new commits. Configure here.