Provides Redis usage patterns for caching, pub/sub, streams, sessions, rate limiting, and leaderboards with naming conventions, TTL strategies, and eviction policies.
Ships in claude-skills-collection. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
| Besoin | Pattern | Structure de données |
|---|---|---|
| Cache lecture | Cache-aside / Write-through | String, Hash |
| Session utilisateur | Session store | Hash + TTL |
| Communication asynchrone | Pub/Sub | Channel |
| File d'attente durable | Streams | Stream |
| Compteur / Rate limiting | Incr atomique | String |
| Classement | Leaderboard | Sorted Set |
| Déduplication / ensemble | Membership | Set |
| Comptage unique approx. | HyperLogLog | HLL |
Convention : {app}:{entité}:{id}:{sous-clé} — toujours en minuscules, séparateur :.
user:42:session # session utilisateur
product:sku:A123:stock # stock d'un produit
rate:api:ip:1.2.3.4 # compteur rate limit
stream:orders # stream de commandes
leaderboard:weekly # classement hebdo
Critères :
prod:, staging:# Cache applicatif : TTL court
SET product:sku:A123 '{"price":29.99}' EX 300
# Session : TTL glissant via EXPIRE à chaque accès
HSET user:42:session token abc123 role admin
EXPIRE user:42:session 3600
# Données de référence : TTL long ou absent (refresh manuel)
SET config:feature-flags '{"darkMode":true}' EX 86400
Politique d'éviction conseillée :
allkeys-lfuvolatile-lfunoeviction (monitoring mémoire obligatoire)redis-cli CONFIG SET maxmemory-policy allkeys-lfu
redis-cli CONFIG SET maxmemory 2gb
import redis, json
r = redis.Redis(host='localhost', port=6379, decode_responses=True)
def get_product(sku: str) -> dict:
key = f"product:sku:{sku}"
cached = r.get(key)
if cached:
return json.loads(cached) # cache hit
product = db.fetch_product(sku) # fallback DB
r.set(key, json.dumps(product), ex=300)
return product
import time
def is_allowed(user_id: str, limit: int = 100, window: int = 60) -> bool:
key = f"rate:{user_id}:{int(time.time()) // window}"
current = r.incr(key)
if current == 1:
r.expire(key, window)
return current <= limit
# Publisher
r.publish("orders:new", json.dumps({"order_id": 99, "amount": 150.0}))
# Subscriber (thread séparé)
pubsub = r.pubsub()
pubsub.subscribe("orders:new")
for message in pubsub.listen():
if message["type"] == "message":
process(json.loads(message["data"]))
# Publier un événement
XADD orders:stream * order_id 99 amount 150 status pending
# Créer un consumer group
XGROUP CREATE orders:stream processors $ MKSTREAM
# Consommer (atomique, at-least-once)
XREADGROUP GROUP processors worker1 COUNT 10 BLOCK 2000 STREAMS orders:stream >
# Acquitter après traitement
XACK orders:stream processors <message-id>
# Ajouter / mettre à jour un score
ZADD leaderboard:weekly NX 4250 "user:42"
# Top 10
ZREVRANGE leaderboard:weekly 0 9 WITHSCORES
# Rang d'un utilisateur (0-based)
ZREVRANK leaderboard:weekly "user:42"
# Pipeline : batch de commandes, 1 aller-retour réseau
pipe = r.pipeline()
pipe.set("key1", "v1", ex=60)
pipe.incr("counter:daily")
pipe.zadd("leaderboard:weekly", {"user:42": 100})
pipe.execute()
# Transaction (MULTI/EXEC) : atomicité, pas de rollback
with r.pipeline() as pipe:
pipe.multi()
pipe.decrby("stock:A123", 1)
pipe.incr("orders:count")
pipe.execute()
Sentinel (failover automatique, setup simple) :
# sentinel.conf
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 10000
Cluster (sharding horizontal, >= 6 noeuds recommandés) :
redis-cli --cluster create \
node1:6379 node2:6379 node3:6379 \
node4:6379 node5:6379 node6:6379 \
--cluster-replicas 1
Critères de choix :
50 GB ou scaling horizontal → Cluster
# Métriques essentielles
redis-cli INFO stats | grep -E "keyspace_hits|keyspace_misses"
redis-cli INFO memory | grep used_memory_human
redis-cli INFO clients | grep connected_clients
redis-cli SLOWLOG GET 10 # top 10 commandes lentes
# Hit ratio cible : > 90%
# Formule : hits / (hits + misses)
Alertes à configurer :
used_memory > 80% du maxmemoryconnected_clients proche de maxclients (défaut 10 000)keyspace_misses en hausse soudaineblocked_clients > 0 de façon persistanteKEYS * en production — bloque Redis (mono-thread). Remplacer par SCAN 0 MATCH prefix:* COUNT 100.{user:42}:cart et {user:42}:session.tls-port 6380, certificats Let's Encrypt ou PKI interne).notify-keyspace-events Ex) pour réagir aux expirations sans polling.redis-benchmark -n 100000 -c 50 -d 256.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
redis-patterns, caching, pub-sub, rate-limiting, session-store
/claude-skills-collection:database-redis-patternsfrom claude-skills-collection
npx claudepluginhub vantaflow/claude-skills-collection --plugin claude-skills-collection348 skills in this plugin
/agent-a2a-protocol-guideGuide du protocole Agent-to-Agent (A2A) de Google pour l'interopérabilité entre agents IA — découverte, communication et collaboration inter-agents, avec exemples de code, critères de décision et pièges à éviter. Se déclenche avec "A2A", "agent-to-agent", "protocole A2A", "Google A2A", "interopérabilité agents". Also triggers on "agent-to-agent protocol", "agent interoperability", "connect two agents"./agent-agent-observabilityInstrumentation technique d'un agent IA — tracing distribué des appels LLM et outils, spans, métriques custom, corrélation de logs et dashboards de supervision. Pour les alertes et garde-fous de production, voir agent-monitoring-setup. Se déclenche avec "observabilité agent", "tracing agent", "LangSmith", "Langfuse", "OpenTelemetry agent", "spans LLM", "corréler les logs agent". Also triggers on "trace my agent", "LLM tracing", "agent spans"./agent-api-caller-subagentSous-agent spécialisé dans les appels API REST/GraphQL avec retry, auth et transformation de données. Se déclenche avec "sous-agent API", "API caller agent", "agent qui appelle une API", "REST agent", "HTTP agent", "API integration subagent", "external API agent". Also triggers on "subagent that calls an API", "API calling agent", "agent HTTP requests".Other plugins' skills for the same job