home / skills / harborgrid-justin / lexiflow-premium / client-side-cache-normalization
/frontend/.github-skills/client-side-cache-normalization
This skill implements a normalized client-side cache to keep React app data consistent, auto-updating UI and efficient entity management.
npx playbooks add skill harborgrid-justin/lexiflow-premium --skill client-side-cache-normalizationReview the files below or copy the command above to add this skill to your agents.
---
name: client-side-cache-normalization
description: Implement a normalized entity cache to maintain data consistency across a React app.
---
# Client-Side Cache Normalization
## Summary
Implement a normalized entity cache to maintain data consistency across a React app.
## Key Capabilities
- Flatten nested API responses.
- Automatic UI updates.
- Garbage collect entities.
## PhD-Level Challenges
- Handle polymorphic data types.
- Resolve relationships.
- Optimize read performance.
## Acceptance Criteria
- Demonstrate consistency.
- Provide a schema.
- Benchmark retrieval speeds.
This skill implements a normalized entity cache for client-side React applications to keep data consistent across the UI. It flattens nested API responses into a single source of truth, enabling automatic UI updates and targeted cache invalidation. The implementation includes garbage collection of unused entities and tools to benchmark retrieval performance.
The cache ingests server responses and normalizes them into entity tables keyed by type and id. Components read derived queries from the normalized store; updates to any entity automatically notify dependents so the UI refreshes without refetching entire payloads. The system resolves relationships by storing references rather than nested objects, supports polymorphic types with type-discriminated records, and periodically garbage-collects orphaned entities.
How do polymorphic entities work in the cache?
Store a type discriminator with each record and key entities by (type, id). Selectors can switch logic by type to recompose views.
How is garbage collection handled?
Track reference counts from root queries and relationships; periodically remove entities with zero references or use a deterministic LRU policy.