Redis and Valkey — data structures for the job (strings, hashes, sorted sets, streams), TTLs and eviction policies, persistence modes, atomicity with Lua/transactions, distributed locks caveats, rate limiting, queues, memory sizing, cluster mode. Use for caching, rate limiting, queues or ephemeral state in Redis (Redis, Valkey, cache, rate limit, lock, streams).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Redis?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-redis)
---
name: redis
description: Redis and Valkey — data structures for the job (strings, hashes, sorted sets, streams), TTLs and eviction policies, persistence modes, atomicity with Lua/transactions, distributed locks caveats, rate limiting, queues, memory sizing, cluster mode. Use for caching, rate limiting, queues or ephemeral state in Redis (Redis, Valkey, cache, rate limit, lock, streams).
metadata:
category: data
---
# Redis
## Purpose
Use Redis for fast ephemeral state without treating it as a source of truth.
**Use when:** caches, counters, rate limits, queues.
**Not for:** durable primary storage.
## Inputs
- Use case, data volume, durability needs.
## Outputs
- Key design, TTL/eviction policy, memory estimate.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "redis"` for prior decisions, patterns and anti-patterns.
## Steps
1. **Structure.** Choose the data structure fitting the operation.
Done when operations are O(1)/O(log n).
2. **Keys.** Namespaced keys with tenant; TTL on everything ephemeral.
Done when no keys without TTL unless justified.
3. **Atomicity.** Use Lua or MULTI for multi-step updates.
Done when races are impossible.
4. **Capacity.** Estimate memory; set `maxmemory-policy`.
Done when eviction behaviour is defined.
## Best practices
- Sliding-window rate limits with sorted sets or GCRA.
- Avoid `KEYS` in production; use `SCAN`.
## Common mistakes
- Using Redlock as a correctness guarantee.
- Huge keys blocking the server.
## Example
Per-account password reset limit: `INCR` with `EXPIRE` in Lua; key `rl:reset:{tenant}:{account}`.
## Reusable prompt
```text
Apply the Redis skill (.agents/skills/redis/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Design keys, structures, TTLs, atomic operations and memory/eviction policy for the use case.
Return: Key design, TTL/eviction policy, memory estimate..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```