> database-redis
Expert rules for caching, key management, and performance in Redis. Use when implementing Redis caching strategies, managing key namespaces, or optimizing Redis performance. (triggers: **/*.ts, **/*.js, **/redis.config.ts, redis, cache, ttl, eviction)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/database-redis?format=md"Redis Best Practices
Priority: P0 (CRITICAL)
- Security:
- Access Control: Use Redis 6.0+ ACLs (
ACL SETUSER) to restrict commands by user/role. - Encryption: Always enable TLS for data-in-transit (standard in managed Redis like Azure/AWS).
- Dangerous Commands: Disable or rename
FLUSHALL,KEYS,CONFIG, andSHUTDOWNin production.
- Access Control: Use Redis 6.0+ ACLs (
- Connection Resilience:
- Pooling: Use connection pooling with tuned high/low watermarks to avoid connection churn.
- Timeouts: Set strict
read_timeoutandconnect_retriesto handle transient network saturation.
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.
- Namespacing: Use colons to namespace keys (e.g.,
- Commands & Performance:
- O(N) Avoidance: Use
SCANinstead ofKEYS. UseUNLINKinstead ofDELfor background reclamation of large keys. - Lua Scripting: Prioritize
EVALSHAfor atomic logic; ensure scripts are pre-loaded to save bandwidth. - Massive Range: Limit
ZRANGE,HGETALL, andLRANGEresults with offsets/limits.
- O(N) Avoidance: Use
- Memory Management:
- Eviction Strategy: Use
allkeys-lrufor general caches andvolatile-lrufor mixed persistent/ephemeral data. - Lazy Freeing: Enable
lazyfree-lazy-evictionandlazyfree-lazy-expire(Redis 4.0+) to offload cleanup from the main thread. - Monitoring: Watch
Used Memory RSSvsUsed Memory Dataset. Large fragmentation suggests a need forMEMORY PURGEor scaling.
- Eviction Strategy: Use
Anti-Patterns
- Primary DB Fallacy: Never use Redis as the ONLY source of truth for critical data.
- Large Value Blobs: Avoid single values > 100KB. Break them into smaller keys or use Hashes.
- JSON Overhead: Favor Hashes (
HSET) for object properties to allow O(1) field access without decoding a full JSON string. - Unmonitored Growth: Letting keys grow without TTL or proper eviction monitoring.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)