Design an Application Caching Strategy
Design a complete Redis caching strategy with appropriate patterns, TTL policy, invalidation, and stampede protection.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Tu es un architecte systèmes expert en stratégies de mise en cache et en optimisation des performances applicatives. Je dois mettre en place une stratégie de cache robuste pour mon application.
Contexte de l'application :
- Type : [EX: API REST à fort trafic, application web B2C, plateforme de données]
- Stack : [EX: Node.js + PostgreSQL, Python + MongoDB]
- Solution de cache envisagée : [EX: Redis 7, Memcached, cache en mémoire]
- Trafic actuel : [EX: 1000 requêtes/minute, pics à 5000]
- Problème de performance : [EX: requêtes DB trop lentes, API tierce rate-limited, calculs coûteux]
Données candidates au cache :
[LISTER_LES_TYPES_DE_DONNÉES: ex. profils utilisateurs, résultats de recherche, configurations, sessions, tokens JWT révoqués]
Conçois une stratégie de cache complète :
- Analyse des données : classe chaque type de donnée par fréquence d'accès, taux de modification et coût de recalcul pour prioriser ce qui mérite d'être caché.
- Patterns de cache : recommande et implémente les patterns appropriés (Cache-Aside, Write-Through, Write-Behind, Read-Through) pour chaque cas d'usage.
- Politique d'expiration (TTL) : définis des TTL appropriés pour chaque type de donnée avec justification.
- Stratégie d'invalidation : comment invalider le cache lors des mises à jour des données (invalidation par clé, pattern, event-driven).
- Gestion des ratés de cache (Cache Miss) : protection contre le Cache Stampede (thundering herd) et le Cache Penetration.
- Cache distribué : considérations pour un environnement multi-instances (Redis Cluster, serialisation).
- Métriques : métriques à surveiller (hit rate, miss rate, memory usage, évictions) et seuils d'alerte.
Personalize this prompt with Léa
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why this prompt works
<p>This prompt is structured to approach caching as a complete systems engineering problem. The initial analysis by access frequency and recomputation cost is the most important step: caching the wrong data (data that changes constantly or is rarely accessed) is worse than not caching at all because it adds complexity without benefit.</p><p>Protection against Cache Stampede (thundering herd) is often ignored until the first production incident: when a cache expires, all simultaneous requests hit the database at once, causing exactly the overload you were trying to avoid. This prompt forces anticipation of this scenario.</p><p>Requesting specific metrics with alert thresholds transforms the design into an observable system: a hit rate below 80% generally indicates a bad TTL policy or overly aggressive invalidation, metrics that allow continuous cache tuning in production.</p>
Use Cases
Expected Output
A complete caching strategy with data analysis, recommended patterns, TTL policy, invalidation strategy, and monitoring metrics.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Ajoute une section "Analyse des coûts de cache vs recalcul" pour justifier le TTL de chaque donnée en fonction de son volume et de son taux d'obsolescence acceptable. Cela évite de cacher des données rarement lues qui consomment inutilement de la mémoire.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
Implement CSP with nonces
Prevent XSS with strict CSP
Debug a Production Error
Quickly analyze a production error with a structured Root Cause Analysis approach and an immediate action plan.
Implement JWT authentication
Add JWT auth to an API
GitHub Copilot Prompt for Generating JavaScript Code
GitHub Copilot, the AI-powered programming assistant developed by GitHub and OpenAI, has transformed the way developers write JavaScript code. By leveraging billions of lines of open-source code, Copilot can generate complete functions, classes, modules, and even entire architectures from simple natural language descriptions. To get the most out of this tool, mastering the art of prompt engineering for code generation is essential. A well-structured prompt produces clean, performant JavaScript code that adheres to modern best practices (ES2024+, implicit typing, error handling, modularity). In this guide, we offer optimized prompts for GitHub Copilot that will help you generate professional-grade JavaScript code, whether you're developing a REST API, a frontend component, a utility script, or complex business logic. Each prompt is designed to provide sufficient context to Copilot while allowing the flexibility needed for relevant and project-adapted generation.