Caching mechanism
The caching mechanism ensures that repeated infrastructure scans,
analyses, and dependency mappings are efficiently served without redundant API calls or
reprocessing. The caching mechanism
Key responsibilities of the caching mechanism
This section describes the key actions and responsibilities of the caching mechanism.
Avoid redundant computation
Before performing a new scan, analysis, or mapping, the system checks the cache for an existing result that matches the input dataset and request parameters. If found, the cached response is immediately returned, significantly reducing processing overhead.
The compare_infrastructure_data
Cache AI-powered reports and dependency graphs
Both documentation reports and dependency mappings generated by Amazon Bedrockare stored with associated metadata. Cached entries include analysis type, input file fingerprints, timestamps, and processing details, so that repeat requests can be served instantly.
The check_ai_report_cache
Track and expose cache statistics
The system provides a /cache/stats endpoint to expose cache utilization
metrics, such as total cache hits, misses, and file counts. A cache
hit is an event where a requested resource or result is found in the cache,
allowing instant retrieval without repeating the underlying computation or API call. A
cache miss is an event where no matching cached resource is found,
triggering a fresh scan or analysis to generate new results which are then cached.
This enables observability into how often caching is used and how much computation is being saved.
The get_cache_stats
Enable cache maintenance and cleanup
Through the /cache/cleanup endpoint, old or stale cache files can be
removed based on configurable retention periods. This approach prevents uncontrolled cache
growth and ensures storage remains efficient over time.
The cleanup_old_cache
Workflow of the caching mechanism
The caching mechanism uses the following workflow:
-
Cache lookup – When a request for documentation generation, infrastructure analysis, or resource mapping is received, the system first queries the cache with the normalized input data and request type.
-
Cache hit – If a valid cached entry is found, the system enriches it with request-specific metadata (processing time, file details, and
served-from-cacheflags) and immediately returns the cached result to the client. -
Cache miss – If no valid cache entry is found, the system processes the request normally by calling AWS APIs or Amazon Bedrock, generates fresh results, and then saves them to the cache for future reuse.
-
Cache monitoring and cleanup – Administrators can retrieve real-time statistics or trigger cache cleanup to remove entries older than a defined threshold (default 30 days). This keeps the cache performant and prevents excessive storage usage.