What does this skill do?

The Redis Patterns Guide is a practical reference for Redis patterns used in production applications. It covers cache-aside with TTL, atomic rate limiting with Lua, distributed locks with SET NX PX, Redis Streams as a persistent queue, Pub/Sub, and connection management with pooling and eviction policies.

Cache-Aside Cache with TTL
It serves reads from Redis with a configured expiration time and reduces the load on the database.
Rate Limiting with a Sliding Window
Implement atomic throttling in APIs using Lua scripts and sorted sets.
Distributed Lockouts
Coordinate workers with SET NX PX and secure authentication using a UUID token.
Redis Streams as a Persistent Queue
Reliable messaging with consumer groups, explicit acknowledgment, and at-least-once delivery.

Usage examples

⚡ Cache with TTL
Add a cache-aside cache layer with a TTL of 1 hour for the products in my API.
🚦 Rate limiting
Implement rate limiting with a 60-second sliding window and a limit of 100 requests per user.
🔒 Distributed Lock
Create a distributed lock to coordinate workers that process payments with a 5-second TTL.
📨 Long-lasting streams
Configure a Redis Streams consumer with a processor group and at-least-once delivery.

Features

Cache-Aside and Write-Through Cache policies with mandatory TTL to prevent indefinite memory growth.
Atomic Rate Limiting with Lua Sliding window with Sorted Sets and Lua scripts for guaranteed atomicity.
Distributed Locks with SET NX PX Secure acquisition and release using UUID tokens and Lua comparison scripts.
Redis Streams and Pub/Sub Long-running queues with consumer groups and ACK, plus more "fire-and-forget" distribution with Pub/Sub.
Pooling and Eviction Policies Configuring the connection pool and selecting a policy based on data type and load.

Frequently asked questions

This isn't a skill that connects to Redis via MCP. It's a reference guide to patterns, but you need a running Redis instance to apply the examples.
Yes, both. Streams with at-least-once delivery and explicit acknowledgment; Pub/Sub as a fire-and-forget broadcast with no delivery guarantees.
It depends on the situation: `allkeys-lru` for general caching, `noeviction` for queues or critical data, and `volatile-ttl` to prioritize long-lived data.
Yes. The examples are in Python, but the patterns apply to any Redis client that supports Lua scripts and the SET NX and PX commands.
Redis Patterns — Production Patterns with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.