Agent-skills-standard database-redis
Optimize Redis caching, key management, and performance. Use when implementing Redis caching strategies, managing key namespaces, or optimizing Redis performance. (triggers: **/*.ts, **/*.js, **/redis.config.ts, redis, cache, ttl, eviction)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/database/database-redis" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-database-redis && rm -rf "$T"
manifest:
skills/database/database-redis/SKILL.mdsource content
Redis Best Practices
Priority: P0 (CRITICAL)
- Security:
- Access Control: Use Redis 6.0+ ACLs (
) to restrict commands by user/role.ACL SETUSER - Encryption: Always enable TLS for data-in-transit (standard in managed Redis like Azure/AWS).
- Dangerous Commands: Disable or rename
,FLUSHALL
,KEYS
, andCONFIG
in production.SHUTDOWN - Connection Resilience:
- Pooling: Use connection pooling with tuned high/low watermarks to avoid connection churn.
- Timeouts: Set strict
andread_timeout
to handle transient network saturation.connect_retries
Guidelines
- Key Design:
- Namespacing: Use colons to namespace keys (e.g.,
,app:user:123
).rate:limit:ip:1.1.1.1 - Readability vs Size: Keep keys descriptive but compact; avoid keys > 512 bytes.
- Commands & Performance:
- O(N) Avoidance: Use
instead ofSCAN
. UseKEYS
instead ofUNLINK
for background reclamation of large keys.DEL - Lua Scripting: Prioritize
for atomic logic; ensure scripts pre-loaded to save bandwidth.EVALSHA - Massive Range: Limit
,ZRANGE
, andHGETALL
results with offsets/limits.LRANGE - Memory Management:
- Eviction Strategy: Use
for general caches andallkeys-lru
for mixed persistent/ephemeral data.volatile-lru - Lazy Freeing: Enable
andlazyfree-lazy-eviction
(Redis 4.0+) to offload cleanup from main thread.lazyfree-lazy-expire - Monitoring: Watch
vsUsed Memory RSS
. Large fragmentation suggests need forUsed Memory Dataset
or scaling.MEMORY PURGE
Anti-Patterns
- No sole truth in Redis: Always persist critical data to durable primary database.
- No large blobs: Split values > 100KB into smaller keys or use Hashes for field access.
- No JSON for objects: Use
for object fields to enable O(1) access without full decode.HSET - No TTL-less keys: Set TTL or eviction policy on all non-permanent keys to prevent unbounded growth.