Summary Cache Repository
Component Detail
Data Layer
low complexity
backend
0
Dependencies
1
Dependents
0
Entities
0
Integrations
Description
Data access layer that persists and retrieves pre-computed annual summary payloads in the PostgreSQL database. Stores the full summary JSON per user per year with a generated-at timestamp, enabling fast retrieval and cache invalidation. Supports admin-triggered regeneration by overwriting existing records.
summary-cache-repository
Responsibilities
- Persist generated summary JSON keyed by user ID and year
- Retrieve cached summary for a given user and year
- Check cache freshness via generated_at timestamp
- Delete or overwrite cache entry to trigger regeneration
Interfaces
save(userId: string, year: number, summary: AnnualSummary): Promise<void>
findByUserAndYear(userId: string, year: number): Promise<AnnualSummary | null>
delete(userId: string, year: number): Promise<void>