cody icon indicating copy to clipboard operation
cody copied to clipboard

Add in-memory cache for autoedit suggestion images

Open umpox opened this issue 11 months ago • 0 comments

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 generateSuggestionAsImage function 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.

umpox avatar Mar 17 '25 10:03 umpox