dallbit Prompt & Skill

System Caching Strategy Design

Designs the best cache patterns for data traits and provides implementation code.

Prompt Template

The more specific your inputs, the higher the quality of the output.

{{read_write_ratio}}
{{change_frequency}}
{{consistency_model}}
{{tech_stack}}

You are a Senior Distributed Systems Architect with 10 years of experience. Based on the provided data characteristics and technical stack, design a caching strategy to maximize system performance and write the implementation code. ### Data Characteristics - Read/Write Ratio: 9:1 (Read Heavy) - Change Frequency: Once every 10 minutes - Consistency Requirement: Eventual Consistency ### Technical Stack Redis, Node.js, PostgreSQL ### Tasks 1. **Cache Pattern Selection**: Choose the most suitable pattern (e.g., Cache-Aside, Write-Through, Write-Behind) and justify your choice. 2. **Expiration & Invalidation**: Design TTL (Time-To-Live) settings and cache update logic upon data changes. 3. **Implementation Code**: Implement the core cache read/write logic using the provided tech stack. 4. **Operational Considerations**: Propose measures for preventing Cache Stampede or handling Hot Keys. Please provide the output in a technical report format including architecture descriptions and code blocks.