P
💻DeveloppementAdvancedAll AIs

Create a High-Performance Scalable Redis Cache System

A complete prompt to design and implement a Redis cache system with invalidation strategies, error handling and monitoring.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un architecte backend senior spécialisé en systèmes distribués et en optimisation de performance. Conçois un système de cache Redis complet pour mon application.

Contexte technique

  • Langage / Framework : [LANGAGE_ET_FRAMEWORK] (ex : Node.js/Express, Python/FastAPI, Java/Spring Boot)
  • Type d'application : [TYPE_APPLICATION] (ex : e-commerce, SaaS multi-tenant, API publique, réseau social)
  • Base de données principale : [BASE_DE_DONNEES] (ex : PostgreSQL, MongoDB, MySQL)
  • Volume estimé : [NOMBRE_REQUETES_PAR_SECONDE] requêtes/seconde en pic
  • Infrastructure : [INFRASTRUCTURE] (ex : AWS ElastiCache, Redis auto-hébergé, Docker Compose, Kubernetes)

Ce que je veux

  1. Architecture du cache :

    • Propose une stratégie de cache adaptée (Cache-Aside, Read-Through, Write-Through, Write-Behind) en justifiant ton choix
    • Définis la structure des clés Redis avec un naming convention clair (préfixes, séparateurs, versioning)
    • Recommande les structures de données Redis appropriées (String, Hash, Set, Sorted Set, Stream) pour chaque type de donnée à cacher
  2. Implémentation complète :

    • Écris une classe/module de cache réutilisable avec : connexion (pool), get, set, delete, invalidation par pattern
    • Implémente le pattern Cache-Aside avec gestion du cache stampede (mutex/lock)
    • Ajoute un mécanisme de sérialisation/désérialisation (JSON, MessagePack ou Protocol Buffers)
    • Gère les erreurs gracieusement : si Redis tombe, l'application doit continuer à fonctionner (circuit breaker)
  3. Stratégie d'invalidation :

    • Définis des TTL adaptés par type de ressource (données chaudes vs froides)
    • Implémente l'invalidation par tags/groupes (ex : invalider tout le cache d'un utilisateur)
    • Propose un mécanisme de cache busting pour les déploiements
    • Gère la cohérence cache/base de données avec un pattern événementiel si pertinent
  4. Patterns avancés :

    • Rate limiting basé sur Redis (sliding window)
    • Cache distribué avec Redis Cluster ou Sentinel (si pertinent pour le volume)
    • Mise en cache de sessions utilisateur
    • Cache de résultats de requêtes complexes avec invalidation intelligente
  5. Monitoring et observabilité :

    • Métriques à suivre : hit ratio, latence, mémoire utilisée, évictions
    • Intègre un système de logging des opérations cache (hit/miss/error)
    • Propose une configuration d'alertes
  6. Configuration Redis :

    • Fichier redis.conf optimisé pour mon cas d'usage
    • Politique d'éviction recommandée (allkeys-lru, volatile-ttl, etc.)
    • Configuration mémoire et persistence (RDB/AOF)

Fournis le code complet, commenté, avec des tests unitaires pour les composants critiques. Inclus un fichier Docker Compose pour l'environnement de développement avec Redis.

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 guides AI to produce a production-quality Redis cache system. By specifying your <strong>language/framework</strong>, <strong>application type</strong> and <strong>infrastructure</strong>, you get code directly integrable into your project, not a generic tutorial.</p><p>The prompt structure covers the five pillars of a robust cache: <strong>architecture</strong> (which strategy for which need), <strong>implementation</strong> (reusable code with error handling), <strong>invalidation</strong> (the most complex caching problem), <strong>advanced patterns</strong> (rate limiting, sessions) and <strong>monitoring</strong>. Each section forces the AI to justify its technical choices rather than proposing a default solution.</p><p>For better results, be specific about your <strong>variables</strong>: a cache for a REST API at 100 req/s is nothing like a cache for an e-commerce site at 10,000 req/s. Also specify your constraints (budget, team, existing technical debt). You can iterate by asking to dive deeper into a specific section, for example <strong>"Detail the tag-based invalidation part with concrete examples for my data model"</strong>.</p>

Use Cases

Optimize REST API performance by caching frequent responsesSet up user session caching for a high-traffic web applicationReduce load on a PostgreSQL or MongoDB database with an intermediate cacheImplement rate limiting and abuse protection via Redis

Expected Output

A complete Redis cache system including: reusable cache module source code in your language, optimized Redis configuration file, development Docker Compose, unit tests, and documentation of key naming conventions and invalidation strategies.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    Précisez vos exigences de cohérence (fréquence de mise à jour, fraîcheur acceptable) et donnez 2-3 exemples concrets de requêtes types avec leurs poids en lecture/écriture. Cela permet de trancher entre Cache-Aside et Write-Through, et de définir des TTL réalistes. Ajoutez aussi un plan de test de charge (montée en charge, panne Redis simulée) pour valider le choix entre Sentinel et Cluster.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateAll AIs

Sora Prompt for Creating E2E Tests

End-to-end (E2E) tests are essential for ensuring application reliability, but writing them remains time-consuming and repetitive. Sora, thanks to its advanced generation capabilities, makes it possible to automate the creation of complete E2E test scenarios in seconds. By formulating a precise prompt describing user journeys, expected interactions, and validation criteria, you obtain structured test suites covering nominal cases as well as edge cases. The prompt engineering approach applied to Sora transforms how QA and development teams approach test coverage. Instead of starting from a blank page, you describe the expected behavior of your application in natural language, and Sora generates the corresponding test code with appropriate assertions. This method significantly reduces the time needed to set up an E2E suite while maintaining a professional quality level. Whether you use Playwright, Cypress, or Selenium, the prompts presented here adapt to your technical stack and the complexity of your application.

383
💻DeveloppementIntermediateAll AIs

Implement rate limiting

Protect APIs from abuse

396
💻DeveloppementIntermediateAll AIs

GitHub Copilot Prompt for Creating a REST API

GitHub Copilot has become an essential assistant for developers looking to accelerate the creation of REST APIs. Thanks to its direct integration into the code editor, it understands the context of your project and generates structured code in real time. Whether you work with Node.js and Express, Python and FastAPI, or Java and Spring Boot, Copilot adapts to your tech stack to produce endpoints conforming to REST conventions. The main challenge lies in formulating the prompt: a well-structured prompt yields a complete API with data validation, error handling, authentication, and documentation. A vague prompt, on the other hand, will produce generic code requiring many adjustments. In this guide, we offer an optimized prompt that fully leverages GitHub Copilot's capabilities to generate a professional, testable, production-ready REST API. You will also discover variants adapted to your experience level as well as practical tips to get the most out of this tool on a daily basis.

425
💻DeveloppementIntermediateAll AIs

GitHub Copilot Prompt for Creating E2E Tests

End-to-end (E2E) tests are essential for validating the overall functionality of an application, but writing them is often time-consuming and repetitive. GitHub Copilot, integrated directly into your code editor, can significantly speed up this process by generating comprehensive test scenarios from natural language descriptions. Whether you use Playwright, Cypress, or Selenium, Copilot understands the context of your project—components, routes, selectors—to produce realistic and maintainable tests. The challenge is to craft prompts precise enough to obtain tests that cover critical user journeys, handle wait states and assertions robustly, while respecting your testing framework's best practices. In this guide, you will find an optimized main prompt as well as variants adapted to your experience level to get the most out of GitHub Copilot in creating your E2E tests.

314