implement QR session chaching using remote directory server(Redis)#135
Open
amritbej wants to merge 1 commit into
Open
implement QR session chaching using remote directory server(Redis)#135amritbej wants to merge 1 commit into
amritbej wants to merge 1 commit into
Conversation
Collaborator
|
Hey, @amritbej Join our discord community -> https://discord.gg/E29mKkQt8 so you can score points for your contribution. |
Contributor
Author
|
Hi @Harxhit , my PR has been gssoc: approved. |
Collaborator
Please join the Discord channel and check the announcements. |
Contributor
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR_DESCRIPTION.md
Summary
Implements Redis-backed public profile caching and offline QR session tokens for Offline QR Mode. Public profile responses are cached for 5 minutes to reduce PostgreSQL reads on repeat views, profile updates invalidate the cache, and a new QR session endpoint returns a short-lived signed profile snapshot token for offline/native QR flows. Closes #46
Type of Change
What Changed
apps/backend/src/routes/public.ts, storing successful profile fetches underprofile:<username>with a 5-minute TTL.X-Cacheresponse headers for public profile responses, returningMISSon DB-backed responses andHITon Redis-backed responses.Cache-Control: public, max-age=300, stale-while-revalidate=60to public profile and QR session responses.GET /api/public/:username/qr-session, returning a signed 10-minute JWT containing the public profile snapshot for offline QR use cases.PUT /api/profiles/me, deleting cached profile keys when a user updates their profile or changes username./api/publicwhile preserving the existing/api/uroute prefix.How to Test
pnpm --filter @devcard/backend testExpected:
X-Cache: MISSX-Cache: HITExpected:
token,tokenType: JWT,expiresIn: 600, andexpiresAt.Checklist
pnpm -r run lintpasses).pnpm --filter @devcard/backend buildpasses).pnpm --filter @devcard/backend test).console.logor debug statements left in the code.Screenshots / Recordings
Not applicable. This is a backend API change.
Additional Context
The Redis plugin was already present and registered in the Fastify app. This PR builds on that plugin and adds the caching, invalidation, headers, QR session token endpoint, and tests required for Offline QR Mode.