Skip to content
Back to skills

Redis Best Practices

ASecurity

Redis best practices for caching, data structures, and in-memory data architecture

  • 43 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
code-qualityperformance

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add baekenough/oh-my-customcode --skill redis-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Redis Best Practices?

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

Security grade badge for Redis Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/baekenough-redis-best-practices/badge)](https://www.skillsdirectory.com/skills/baekenough-redis-best-practices)

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-best-practices
description: Redis best practices for caching, data structures, and in-memory data architecture
scope: core
user-invocable: false
---

# Redis Best Practices

## Caching Patterns

### Cache-Aside (CRITICAL)
- Read: check cache → miss → read DB → set cache
- Write: update DB → invalidate cache
- Best for read-heavy workloads

### Write-Through
- Write: update cache AND DB simultaneously
- Ensures consistency
- Higher write latency

### Write-Behind
- Write: update cache → async DB update
- Lowest latency
- Risk of data loss

## Data Structures

### String
- Simple key-value: `SET key value`
- Counters: `INCR`, `DECR`, `INCRBY`
- Bit operations: `SETBIT`, `BITCOUNT`

### Hash
- Object storage: `HSET user:1 name "Alice"`
- Partial updates: `HINCRBY user:1 visits 1`
- Memory efficient for small hashes

### List
- Queues: `LPUSH`, `RPOP` (FIFO)
- Stacks: `LPUSH`, `LPOP` (LIFO)
- Capped collections: `LTRIM`

### Set
- Unique collections: `SADD`, `SMEMBERS`
- Intersections: `SINTER`
- Random sampling: `SRANDMEMBER`

### Sorted Set
- Leaderboards: `ZADD`, `ZRANGEBYSCORE`
- Rate limiting: `ZADD timestamp`
- Priority queues

### Stream
- Event log: `XADD`, `XREAD`
- Consumer groups: `XGROUP`, `XACK`
- Pub/Sub with persistence

## Performance

### Memory Optimization
- Set maxmemory policy: `allkeys-lru`, `volatile-lru`
- Monitor memory: `INFO memory`
- Use appropriate data structures (Hash vs String)

### Pipelining
- Batch multiple commands
- Reduces round-trip latency
- Use for bulk operations

## High Availability

### Redis Cluster
- Horizontal scaling
- Automatic sharding (16384 slots)
- Multi-master replication

### Redis Sentinel
- Automatic failover
- Monitoring and notifications
- Configuration provider

## References
- [Redis Best Practices](https://redis.io/docs/manual/patterns/)

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.