refactor(posthog): cache posthog queries in Redis#2554
Merged
chrarnoldus merged 5 commits intomainfrom Apr 20, 2026
Merged
Conversation
Contributor
Author
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments: None. Files Reviewed (1 files)
Reviewed by gpt-5.4-20260305 · 551,705 tokens |
Redis-cached payloads were the post-transform output but were re-validated with the original schema on cache hits, causing every cached value to fail schema validation and refetch. Cache the raw pre-transform results instead so the schema parse runs identically on fresh and cached paths.
markijbema
approved these changes
Apr 20, 2026
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.
Summary
unstable_cacheinapps/web/src/lib/posthog-query.tswith Redis-backed caching viaredisGet/redisSet.(name, query) => Promise<Output[]>function shape, so call sites (notifications.ts) don't change.posthog-query:<sha256(name\0query)>. Cached value is the parsed, schema-validated JSON payload. Redis failures (connect/timeout) are caught and fall through to a fresh PostHog query, so this fails open.Verification
pnpm typecheckpnpm lintpnpm formatVisual Changes
N/A
Reviewer Notes
redisSetwhenREDIS_URLis unset —redisSetreturnsfalsein that case and we swallow nothing extra.