Skip to content
Back to skills

Redis Caching Patterns

ASecurity

Use when implementing Redis caching and data structures.

  • 2 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 10, 2026
ai-agentspythonapi

Works with

  • api

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add LoopyLuci/Skills --skill redis-caching-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Redis Caching Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Redis Caching Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/loopyluci-redis-caching-patterns/badge)](https://www.skillsdirectory.com/skills/loopyluci-redis-caching-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: redis-caching-patterns
description: "Use when implementing Redis caching and data structures."
version: 1.0.0
author: Hermes Agent
license: MIT
metadata:
  hermes:
    tags: [redis, caching, pub-sub, streams, sorted-sets, caching-strategies]
    related_skills: [caching-strategies, message-queue-patterns, api-rate-limiting]
---

# Redis Caching Patterns

Implementing Redis caching and data structures — from caching strategies through pub/sub, streams, sorted sets, and rate limiting.

## When to Use

- Implementing Redis caching layers
- Real-time data structures (leaderboards, queues)
- Pub/sub messaging and event streaming
- Distributed rate limiting and locking

## Redis Patterns

```python
import redis.asyncio as redis

class RedisCache:
    def __init__(self): self.r = redis.Redis()
    
    async def cached_query(self, key: str, ttl: int = 300):
        cached = await self.r.get(key)
        if cached: return cached
        
        result = await expensive_query()
        await self.r.setex(key, ttl, result)
        return result

# Distributed rate limiter (sliding window)
class RateLimiter:
    def __init__(self, r): self.r = r
    
    async def allow(self, key: str, max_req: int, window: int = 60):
        now = int(time.time() * 1000)
        pipe = self.r.pipeline()
        pipe.zadd(f"rl:{key}", {now: now})
        pipe.zremrangebyscore(f"rl:{key}", 0, now - window * 1000)
        pipe.zcard(f"rl:{key}")
        pipe.expire(f"rl:{key}", window + 1)
        _, _, count, _ = await pipe.execute()
        return count <= max_req
```

## Verification Checklist

- [ ] Cache strategy chosen (cache-aside, write-through, write-behind)
- [ ] TTLs set appropriately for data freshness
- [ ] Pub/sub for real-time notifications
- [ ] Streams for persistent message queues
- [ ] Sorted sets for leaderboards and range queries
- [ ] Redis Sentinel/Cluster for high availability

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.