KPI Response Cache
Component Detail
Infrastructure
low complexity
backend
1
Dependencies
0
Dependents
0
Entities
0
Integrations
Description
Short-lived server-side cache layer (30-60 second TTL) for KPI aggregation results, reducing repeated PostgreSQL aggregation load on the admin portal home screen without requiring a websocket or real-time pipeline.
kpi-response-cache
Responsibilities
- Cache aggregated KPI results per organization with 30-60 second TTL
- Invalidate cache on demand (e.g. after expense approval or activity save)
- Serve stale-while-revalidate to avoid cold-cache blocking on page load
Interfaces
getCachedKpis(orgId: string): KpiPayload | null
setCachedKpis(orgId: string, payload: KpiPayload, ttlSeconds: number): void
invalidateKpisCache(orgId: string): void