Cache YouTube video metadata with built-in rate limiting, TTL management, and batch lookups to prevent API quota exhaustion in Convex apps.
npm install convex-youtube-cache**Cache and serve YouTube metadata without hitting API limits.**
Drop-in component that handles the full caching lifecycle so you never worry about quota again.
- TTL-based cache with automatic expiration and refresh
- Built-in rate limiting to stay within YouTube API quotas
- Reservation system to prevent duplicate in-flight requests
- Batch lookups for efficient multi-video queries
- Real-time subscriptions for cache updates
The convex-youtube-cache component provides automatic caching with configurable TTL and built-in rate limiting to stay within YouTube API quotas. It includes a reservation system that queues requests when quota is exhausted and implements stale-while-revalidate for fast responses.
Use the getVideos method to fetch metadata for up to 50 videos in a single API call, optimizing quota usage. The component automatically handles caching, rate limiting, and returns an array of VideoMetadata objects with title, description, thumbnails, and channel information.
The convex-youtube-cache component includes built-in rate limiting with configurable daily quotas (default 10,000 units). When quota is exhausted, it creates reservations that wait up to 10 seconds for capacity, then gracefully degrades by returning stale data or null.
The reservation system prevents duplicate in-flight requests by queuing identical video ID requests. Multiple concurrent requests for the same video will wait for a single API call to complete, reducing quota usage and preventing race conditions.
The convex-youtube-cache component includes built-in rate limiting with configurable daily quotas (default 10,000 units per day). When quota is exhausted, it creates reservations that queue requests and wait up to a configurable timeout (default 10 seconds) before gracefully degrading to return stale cached data or null.
Yes, the convex-youtube-cache component provides a getVideos method that supports batch lookups for up to 50 video IDs in a single YouTube API call. This significantly reduces quota usage compared to individual requests and includes the same caching and rate limiting features.
The convex-youtube-cache component implements a stale-while-revalidate strategy. When cached data exceeds its TTL, it returns the stale data immediately for fast response times, then fetches fresh data from the YouTube API in the background if quota is available.
The convex-youtube-cache component provides a getCacheStats method that returns hit rate, quota usage, and active reservations. You can call this from a Convex query to monitor performance and track how efficiently your app is using the YouTube API quota.
Yes, the convex-youtube-cache component includes retry logic with exponential backoff for transient HTTP errors. It supports configurable retry attempts (default 3) and base retry delays (default 1 second) to handle temporary YouTube API failures gracefully.