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

💻DeveloppementAdvancedAll AIs

Implement CSP with nonces

Prevent XSS with strict CSP

0233
💻DeveloppementIntermediateAll AIs

Mistral Prompt for Creating a Prototype

Mistral, the leading French AI model, stands out as a powerful tool for accelerating prototype creation. Whether you're developing a web application, an API, or a digital product, Mistral can generate functional code, structure your architecture, and produce a testable prototype in minutes. Unlike a traditional approach where prototyping requires several days of development, using Mistral allows you to quickly validate an idea by obtaining a complete functional skeleton. The model particularly excels at generating structured code, proposing coherent architectures, and creating basic but functional user interfaces. By crafting a precise prompt that describes your product vision, key features, and technical constraints, you get a prototype that serves as a solid foundation for iteration. This approach is especially popular with startups, product managers, and independent developers looking to test a market hypothesis without investing weeks of development. Here's how to leverage Mistral to turn your idea into a concrete prototype.

0195
💻DeveloppementIntermediateAll AIs

DALL-E Prompt to Generate JavaScript Code

DALL-E, the image generation model developed by OpenAI, is not designed to produce executable JavaScript code. However, it can play a valuable complementary role in a JavaScript developer's workflow. DALL-E excels at creating visuals related to development: user interface mockups, architecture diagrams, data flow schemas, or illustrations to document your code. By crafting precise prompts, you can obtain visual representations of complex JavaScript concepts like closures, the event loop, or design patterns. These visuals then serve as references for implementing your code, creating attractive technical documentation, or designing educational materials. The approach is to use DALL-E as a rapid visual prototyping tool: generate a UI mockup, then translate it into JavaScript components. This method accelerates the design phase and reduces back-and-forth between designers and developers. In this guide, we offer optimized prompts to get the most out of DALL-E in your JavaScript development process, from UI prototyping to visual documentation of your code.

0496
💻DeveloppementIntermediateAll AIs

GitHub Copilot Prompt to Create a Chatbot

GitHub Copilot has become an essential assistant for developers looking to accelerate the creation of conversational applications. Creating a chatbot involves many technical steps: system architecture, conversation flow management, integration of natural language processing APIs, and implementation of a responsive user interface. With a well-structured prompt, GitHub Copilot can generate the essential code, from the backend for message management to the logic for routing user intents. The challenge is to formulate a request precise enough for Copilot to understand the type of chatbot envisioned (customer support, automated FAQ, virtual assistant), the chosen tech stack, and expected features. An effective prompt allows you to go from idea to functional prototype in a fraction of the usual time, while producing maintainable and extensible code. In this guide, you will find an optimized main prompt as well as variants adapted to your expertise level, to fully leverage GitHub Copilot's potential in creating your chatbot.

0271