-
Notifications
You must be signed in to change notification settings - Fork 195
perf(content): KV-cache Sanity lesson overrides (incl. negative cache) #1568
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe changes introduce a KV-based caching layer for Sanity lesson metadata using SHA-1 hashed cache keys. The implementation checks the cache before querying Sanity, stores results with differentiated TTLs (1 hour for hits, 24 hours for misses), and includes error handling for cache operations. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Cache as KV Cache
participant Sanity as Sanity API
Client->>Cache: Check cache (SHA-1 key)
alt Cache Hit
Cache-->>Client: Return cached lesson metadata
else Cache Miss or Error
Cache-->>Client: No cached value
Client->>Sanity: Fetch lesson metadata
Sanity-->>Client: Return metadata
Client->>Client: Merge base + derived values
Client->>Cache: Store result (TTL: 1h for hit, 24h for miss)
Cache-->>Client: Cache stored
Client-->>Client: Return merged metadata
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sanity calls are a mostly-dead override layer but we’re still paying the roundtrip on every
loadLesson().Observed (since deploy):
lesson.loadLessonMetadataFromSanity.groqis ~100ms avgThis change caches both hits and misses in Vercel KV:
That should collapse the Sanity call volume quickly without needing a brittle allowlist.
Added structured logs:
lesson.loadLessonMetadataFromSanity.kv_get_error/...kv_set_errorlesson.loadLessonMetadataFromSanity.groqValidation:
pnpm exec tsc -p tsconfig.json --noEmitpnpm test:ciRefs: #1560
Summary by CodeRabbit