Skip to content

perf(auth): memoize current authenticatable#2144

Open
xHeaven wants to merge 2 commits into
tempestphp:3.xfrom
xHeaven:fix/auth-current-cache
Open

perf(auth): memoize current authenticatable#2144
xHeaven wants to merge 2 commits into
tempestphp:3.xfrom
xHeaven:fix/auth-current-cache

Conversation

@xHeaven
Copy link
Copy Markdown
Member

@xHeaven xHeaven commented Jun 2, 2026

This PR memoizes the current authenticatable within SessionAuthenticator. Previously, each call to current() re-resolved the authenticated model from the database, which caused repeated identical queries during authorization checks that rely on the implicit current subject. The authenticator now caches the resolved authenticatable for the current session identity and invalidates that cache when the identity changes, when a new user is authenticated, or when the session is deauthenticated.

@xHeaven xHeaven requested a review from innocenzi as a code owner June 2, 2026 13:39
@xHeaven xHeaven force-pushed the fix/auth-current-cache branch from afb5438 to a54d529 Compare June 2, 2026 14:04
Comment thread packages/auth/src/Authentication/SessionAuthenticator.php Outdated
@xHeaven xHeaven force-pushed the fix/auth-current-cache branch from a54d529 to 208a8ea Compare June 2, 2026 23:08
Comment thread packages/auth/src/Authentication/SessionAuthenticator.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants