Cache Design
Cache architecture and implementation patterns.
The Package Cache is the intermediary layer between the CaD(configuration as data) Engine and external Git repositories. It maintains in-memory or database-backed representations of repositories, packages, and package revisions to improve performance and reduce load on external repository systems.
The cache is responsible for:
The Package Cache sits between the CaD Engine and Repository Adapters:
CaDEngine
↓
Package Cache
↓
┌──┴────┐
↓ ↓
CR Cache DB Cache
↓ ↓
Repository Adapter
↓
External Repositories (Git)
Key architectural responsibilities:
Performance Optimization: Reduces latency by caching repository data in memory or a database rather than fetching from Git on every request
Repository Lifecycle Management:
Abstraction Layer: Provides a consistent Cache interface with two implementations:
Repository Adapter Integration:
Change Notification:
Cache selection:
The cache implementation is selected at Porch server startup based on configuration:
Both implementations provide the same interface and functionality, differing only in storage mechanism and scalability characteristics.
Singleton pattern:
The cache is instantiated once during Porch server initialization and shared across all operations. This ensures:
Cache architecture and implementation patterns.
CR-based cache implementation details.
Database-based cache implementation details.
Overview of cache functionality and detailed documentation pages.
How the cache integrates with repositories and adapters.