feat: implement Redis-based caching for getSchedule endpoint#22608
feat: implement Redis-based caching for getSchedule endpoint#22608
Conversation
- Add cache utilities with SHA1-based key generation and 10s TTL - Integrate caching into getScheduleHandler with feature flag support - Add cache invalidation on booking creation and schedule updates - Use existing RedisService infrastructure and getShouldServeCache logic - Maintain type safety and existing functionality Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
✅ No security or compliance issues detected. Reviewed everything up to 33c1c57. Security Overview
Detected Code Changes
Reply to this PR with |
…tation - Create new VercelKVService implementing IRedisService interface - Update cache utilities to use VercelKVService instead of RedisService - Add @vercel/kv dependency to apps/web package.json - Maintain existing RedisService for other use cases - Keep same cache functionality with 10s TTL and SHA1 keys Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
|
This PR is being marked as stale due to inactivity. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (08/06/25)1 reviewer was added to this PR based on Keith Williams's automation. |
|
This was done in #22787 |
feat: implement Redis-based caching for getSchedule endpoint
Summary
Implements a Redis-based caching strategy for the
getScheduleHandlerendpoint to mitigate DDoS-like behavior from repeated identical requests. The implementation uses Vercel KV instead of the existing Redis infrastructure as requested.Key Changes:
packages/features/redis/VercelKVService.ts): ImplementsIRedisServiceinterface using@vercel/kvpackages/lib/cache.ts): SHA1-based cache key generation, 10-second TTL, error handlinggetScheduleHandler: Checks cache before computation, respects existinggetShouldServeCachefeature flags@vercel/kvpackage added to web appReview & Testing Checklist for Human
KV_URL,KV_REST_API_URL, andKV_REST_API_TOKENenvironment variables are properly set upget(),set(),expire(),lpush()methods behave identically to Redis, especially return types and error handlinggetShouldServeCachereturns true for relevant teams/usersRecommended test plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TD Client[Client Request] --> Handler["getSchedule.handler.ts<br/>(Modified)"] Handler --> FeatureFlag["getShouldServeCache<br/>(Existing)"] FeatureFlag -->|enabled| Cache["cache.ts<br/>(Modified)"] FeatureFlag -->|disabled| Direct[Direct Computation] Cache --> VercelKV["VercelKVService<br/>(New)"] Cache -->|miss| Compute["availableSlotsService<br/>(Existing)"] Compute --> Cache Booking["handleNewBooking.ts<br/>(Modified)"] --> Invalidate["invalidateScheduleCache"] Schedule["updateSchedule.ts<br/>(Modified)"] --> Invalidate Invalidate --> VercelKV subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFF class Handler,Cache,VercelKV,Booking,Schedule major-edit class Invalidate minor-edit class Client,FeatureFlag,Direct,Compute contextNotes
RedisServiceintact for other use cases.Session details: Requested by @hbjORbj
Link to Devin run: https://app.devin.ai/sessions/09b101be4b2c48f4a848e09b37ece640