用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mikailustuner/OmniRule --skill redis-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | redis-patterns |
| description | Redis Patterns: Data structures, cache strategies, pub/sub, distributed locks. |
| triggers | {"keywords":["Redis","cache","session","pub/sub","rate limit","distributed lock","sorted set","pipeline"]} |
| auto_load_when | Using Redis for caching or pub/sub |
| agent | infra-specialist |
| tools | ["Read","Write","Bash"] |
Focus: In-memory data structures, caching, session storage
String:
├── Simple key-value
├── Used for: cache, counters, flags
└── Commands: SET, GET, INCR
Hash:
├── Field-value pairs
├── Used for: objects, metadata
└── Commands: HSET, HGET, HGETALL
List:
├── Ordered strings
├── Used for: queues, logs
└── Commands: LPUSH, RPOP, LRANGE
Set:
├── Unique strings, no order
├── Used for: tags, unique visitors
└── Commands: SADD, SMEMBERS
Sorted Set:
├── Score-value pairs, ordered
├── Used for: rankings, time-series
└── Commands: ZADD, ZRANGE
Cache patterns:
├── Cache-aside: App checks cache first
├── Write-through: Update cache on write
├── Write-behind: Async cache update
└── Refresh-ahead: Proactive refresh
TTL: Set expiration for all cache keys
Use Redis for:
├── Session storage
├── Real-time features
├── Rate limiting
├── Message queues
├── Pub/sub
├── Leaderboards
└── Caching layer
Avoid Redis for:
├── Primary data store (without persistence)
├── Complex queries
├── Large blobs (>1MB)
└── Data that doesn't fit in RAM
Redlock pattern:
├── Acquire lock with SET NX + TTL
├── Only one client succeeds
├── Release with DEL
└── Add expiration to prevent deadlocks
Consider: Redisson library
Pattern:
├── Channel-based messaging
├── Publisher → Channel → Subscribers
└── Fire-and-forget
Use cases:
├── Real-time notifications
├── Cache invalidation
└── Event distribution
Best practices:
├── Use pipelines for bulk ops
├── Choose right data structure
├── Avoid KEYS in production (use SCAN)
├── Monitor memory
└── Use connection pooling
RDB (snapshots):
├── Periodic snapshots
├── Good for backups
└── Data loss possible
AOF (append-only):
├── Every write logged
├── Slower, more data
└── More durable
(End of file - 82 lines)
❌ Storing large objects (>1MB) in Redis
✅ Redis for hot, small data; use S3/DB for large blobs
❌ No TTL on cached keys — memory fills up
✅ Every cache key has a TTL; use allkeys-lru eviction policy
❌ KEYS * in production (blocks Redis)
✅ Use SCAN with cursor for key iteration
❌ Using Redis as primary data store
✅ Redis is cache / queue / pub-sub — not source of truth
❌ No Redis Sentinel / Cluster for production
✅ Sentinel for HA; Cluster for horizontal scale
| Use case | Redis type | Command |
|---|---|---|
| Cache key-value | String | SET key val EX 300 |
| Rate limiting | String + INCR | INCR + EXPIRE |
| Session store | Hash | HSET session:id field val |
| Queue | List | LPUSH / BRPOP |
| Pub/sub | Pub/Sub | PUBLISH / SUBSCRIBE |
| Leaderboard | Sorted Set | ZADD / ZRANGE |
| Distributed lock | String + NX | SET lock nx ex 30 |