cody
cody copied to clipboard
Add in-memory cache for autoedit suggestion images
Description
This PR implements an in-memory cache for autoedit suggestion images using the AutoeditRequestID as the cache key. The cache prevents regenerating the same image for repeated requests, improving performance.
Changes
- Added Map to store generated images keyed by
AutoeditRequestID - Updated
generateSuggestionAsImagefunction to check the cache first - Added cache clearing functions for both individual images and the entire cache
- Updated all call sites to pass the requestId parameter when available
- Added tests for the caching functionality
Testing
Added tests that verify:
- Images are cached correctly when using the same requestId
- Cache is properly invalidated when clearing specific images
These tests verify both the caching functionality and cache invalidation works as expected.