feat: add framework-agnostic googleapis caching layer to prevent rate limiting#21933
Closed
devin-ai-integration[bot] wants to merge 7 commits intomainfrom
Closed
feat: add framework-agnostic googleapis caching layer to prevent rate limiting#21933devin-ai-integration[bot] wants to merge 7 commits intomainfrom
devin-ai-integration[bot] wants to merge 7 commits intomainfrom
Conversation
… limiting - Implement GoogleApiCache class with configurable cache window and request deduplication - Create CacheClient abstraction with EdgeCacheClient (Next.js) and RedisCacheClient (Nest.js) - Add CachedCalendarClient wrapper for calendar_v3.Calendar with selective caching - Integrate cachedFetch manager at CalendarAuth level for transparent API call interception - Target calendar.events.*, freebusy.query, calendarList.list methods for caching - Add explicit dependency injection in both Next.js and Nest.js without framework detection - Wire up cache client injection at handleNewBooking invocation level to avoid prop-drilling - Include comprehensive documentation, testing, and deployment guides - Maintain compatibility with existing CalendarCache and booking flow Co-Authored-By: zomars@cal.com <zomars@cal.com>
Contributor
Author
🤖 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:
|
- Add missing context and acl properties to CachedCalendarClient for Calendar interface compatibility - Fix iterator compatibility issue in GoogleApiCache using Array.from() - Replace 'any' types with 'unknown' for better type safety - Fix unused variable warnings by prefixing with underscore Co-Authored-By: zomars@cal.com <zomars@cal.com>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
- Add proper type assertion for cached response return value (unknown -> T) - Fix iterator compatibility issue using Array.from() for Map iteration - All TypeScript compilation errors now resolved locally (yarn type-check:ci passes) Co-Authored-By: zomars@cal.com <zomars@cal.com>
…port - Moves GoogleApiCacheService and GoogleApiCacheModule to apps/api/v2/src/modules/googleapis-cache/ - Updates all import statements to use new module location - Resolves prettier formatting errors with TypeScript decorators - Fixes 'Cannot find module ./NestJsIntegration' TypeScript compilation errors - Local yarn type-check:ci passes successfully Co-Authored-By: zomars@cal.com <zomars@cal.com>
Contributor
E2E results are ready! |
…ency - Creates mock provider using NoOpCacheClient for test environments - Follows existing MockedRedisService pattern for consistency - Resolves 'Unable to find environment variable: UPSTASH_REDIS_REST_URL' errors - Ensures E2E tests can run without Redis configuration - Updates all 14 E2E test files to use the mock provider Co-Authored-By: zomars@cal.com <zomars@cal.com>
…ider override - Replace string token with actual class reference in .overrideProvider() calls - Follows NestJS testing patterns from withApiAuth.ts and withNextAuth.ts - Resolves Redis dependency injection errors in E2E tests - Ensures mock provider takes effect during module compilation Co-Authored-By: zomars@cal.com <zomars@cal.com>
…compilation errors - Adds GoogleApiCacheService import to booking-fields.e2e-spec.ts - Adds GoogleApiCacheService import to api-key-bookings.e2e-spec.ts - Adds GoogleApiCacheService import to user-emails.e2e-spec.ts - Resolves 'Cannot find name GoogleApiCacheService' compilation errors - Ensures all E2E test files can properly override the provider Co-Authored-By: zomars@cal.com <zomars@cal.com>
devin-ai-integration bot
added a commit
that referenced
this pull request
Jul 1, 2025
- Add framework-agnostic caching system supporting Next.js Edge Cache and Redis - Implement request signature-based deduplication with 30-second default TTL - Support read operations (events.list, events.get, freebusy.query, calendarList.list) - Add per-credential cache isolation for security - Include comprehensive documentation and testing infrastructure - Integrate with booking flow through optional dependency injection - Add NestJS module for Redis cache support in API v2 Based on PR #21933 with updates for main branch compatibility Co-Authored-By: zomars@cal.com <zomars@me.com>
5 tasks
Contributor
Author
|
Closing due to inactivity for more than 7 days. Configure here. |
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.
Framework-Agnostic Google APIs Caching Layer
🎯 Overview
This PR implements a comprehensive framework-agnostic caching layer for Google Calendar API calls to prevent rate limit quota exhaustion. The solution integrates at the
CalendarAuthlevel to intercept all googleapis calls across both Next.js and Nest.js frameworks without requiring framework detection.🏗️ Architecture
Core Components
GoogleApiCache: Request signature-based caching with configurable time windows (default: 30s)CacheClientAbstraction: Framework-specific implementationsEdgeCacheClient: Uses Next.jsunstable_cachefor server-side cachingRedisCacheClient: Leverages existing Redis infrastructure for Nest.jsNoOpCacheClient: Fallback for scenarios where caching is disabledCachedCalendarClient: Wrapper forcalendar_v3.Calendarwith selective cachingCachedFetchManager: Central manager for request deduplicationIntegration Points
handleNewBookinginvocation level🎯 Targeted API Methods
The caching layer focuses on read operations that commonly cause rate limiting:
calendar.events.list- Event listing queriescalendar.events.get- Individual event retrievalcalendar.events.instances- Recurring event instancescalendar.freebusy.query- Availability checkingcalendar.calendarList.list- Calendar enumerationWrite operations (
insert,update,delete) bypass caching to prevent data consistency issues.🔧 Implementation Details
Request Signature Generation
requestId,quotaUser)Cache Management
🚀 Integration Examples
Next.js API Route
Nest.js Module
📊 Benefits
🧪 Testing
yarn type-check:ci)📚 Documentation
Comprehensive documentation included:
ARCHITECTURE.md: System design and component relationshipsINTEGRATION.md: Framework-specific integration guidesDEPLOYMENT.md: Production deployment considerationsTESTING.md: Testing strategies and verification steps🔗 Related
CalendarCachesystem without interferenceOAuthManagerand authentication flows🎉 Link to Devin run
https://app.devin.ai/sessions/37cfda9d9abb43f8a2ee493f50d87417
Requested by: zomars@cal.com
Summary by cubic
Added a framework-agnostic caching layer for Google Calendar API calls to prevent rate limiting, with support for both Next.js and Nest.js through explicit cache client injection.
events.list,events.get, andfreebusy.queryusing a request signature-based cache with a default 30-second window.