β‘ Bolt: Optimize recent issues cache serialization #152
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.
π‘ What:
Optimized the
/api/issues/recentendpoint by caching the serialized JSON string directly instead of the list of Pydantic models (or dicts).Modified
backend/main.pyto store the result ofjson.dumps(data)in the cache.On cache hits, it returns a
Responseobject withmedia_type="application/json"and the pre-serialized content, bypassing FastAPI'sJSONResponseserialization overhead.π― Why:
The
JSONResponseclass performs serialization on every request, even if the data comes from the cache. By caching the final JSON string, we save the CPU cost of serializing the list of issues (which can contain complex nested structures likeaction_plan) on every read. This reduces latency for a frequently accessed endpoint.π Impact:
/api/issues/recentby skipping the serialization step (approx O(N) where N is response size).π¬ Measurement:
tests/test_recent_issues.pyto verify caching behavior and format handling.PR created automatically by Jules for task 15357320750871769866 started by @RohanExploit