redis-architect
Architect-level Redis guidance — deciding what may live in a cache versus a source of truth, key naming and eviction policy, cache-aside and stampede protection, using the right data structure, and the durability limits that turn a cache into an outage. Use when adding Redis for caching, sessions, rate limits or queues.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- redis-architect
- license
- MIT
- metadata
- { "crusor-path": "website-architect/database-engineering-architect/redis-architect", "crusor-domain": "website-architect", "crusor-origin": "original", "crusor-sources": "redis.io/docs/latest; redis.io/docs/latest/develop/reference/eviction", "crusor-triggers": "redis, cache, caching, session store, rate limit, pub sub, eviction, key expiry, valkey", "crusor-verified-on": "2026-10-30" }
- description
- Architect-level Redis guidance — deciding what may live in a cache versus a source of truth, key naming and eviction policy, cache-aside and stampede protection, using the right data structure, and the durability limits that turn a cache into an outage. Use when adding Redis for caching, sessions, rate limits or queues.
- compatibility
- Redis 7+ (or Valkey)
03 SKILL.md 正文
Redis Architect
Redis is fast because it is allowed to lose your data. Everything here follows from that sentence.
When to use
- Read-heavy paths needing sub-millisecond responses.
- Sessions, rate limits, locks, counters, queues, presence.
- A cache in front of a database that remains authoritative.
When NOT to use
- Anything that cannot be regenerated (orders, balances, audit logs).
- As the primary database because "it's faster".
- Large blobs and search — wrong tool.
Decision 1 — What may live here
| Data | Allowed | Rule |
|---|---|---|
| derived caches | yes | always reconstructable from the source |
| sessions | yes | TTL, and re-login is an acceptable loss |
| rate-limit counters | yes | approximate by design |
| queues/dedup keys | yes | consumers must tolerate redelivery |
| business records | no | Postgres/document store |
Every key has an owner (who writes it), a TTL, and a rebuild path.
Decision 2 — Keys and eviction
- Namespaced keys:
app:v1:user:{id}:profile, version in the prefix so a shape change is a new keyspace. - TTL on everything except deliberately durable structures; a key without TTL is a slow leak.
maxmemory-policy:allkeys-lrufor pure caches,volatile-*when some keys must survive,noevictiononly when you handle write errors.- Track hit ratio and evictions; evicting a lot means the cache is a database now.
Decision 3 — Patterns
| Pattern | Use | Cost |
|---|---|---|
| cache-aside | default; app reads cache, falls back to DB, writes back | thundering herd on miss |
| write-through | strong freshness needed | write latency, cache as critical path |
| read-through | library-managed | hides latency from the app |
| stampede lock | hot key after expiry | complexity |
- Stampede: lock + serve stale, or jittered TTLs. Never let N requests recompute the same expensive value.
- Negative caching: cache "not found" briefly or you will hammer the DB.
- Invalidation is the hard part — prefer short TTL + explicit delete on write.
Decision 4 — Data structures
- Strings for blobs/counters, hashes for objects (partial updates), sorted sets for leaderboards/rate windows, streams for queues, sets for membership.
- Avoid fetching a whole large hash to read one field.
SCANnotKEYSin production;UNLINKnotDELfor big values.
Decision 5 — Durability and topology
- RDB/AOF are best-effort: acknowledge the loss window explicitly.
- Replication is async by default; a failover can lose recent writes — never put money in it.
- Sentinel/cluster for HA; cluster only when a single node's memory/throughput is genuinely insufficient (it constrains multi-key ops).
Failure modes at scale
- Redis flushed during an incident → sessions gone, app unusable.
- One giant key (a list with a million entries) blocking the single thread.
KEYS *in production freezing the server.- Cache treated as truth: data "reappears" after eviction.
- TTL jitter absent → synchronized expiry → DB spike every hour.
Verification receipts
- Key inventory: owner, TTL, rebuild path.
- Eviction policy and maxmemory reviewed against workload.
- Hit ratio and eviction count from
INFO stats. - Failure test: Redis down → app degrades (slower), not fails.
- Hot-key and big-key audit (
--bigkeys, slowlog).
04 同仓库更多 Skills
interaction-patterns-architect
Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.
design-system-ops-architect
Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.
design-handoff-architect
Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.
content-microcopy-architect
Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.
ui-ux-implementation-architect
Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.
test-strategy-architect
Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.