Skip to main content

Cache and Redis Guidelines

Use cache for ephemeral or high-read state where correctness and fallback behavior are clear.

Required Cache Design

Every new cache use MUST define:

  • key schema
  • TTL policy
  • invalidation behavior
  • fallback behavior when cache misses/fails

Key Naming

  • Keys MUST be deterministic and namespaced.
  • Recommended format: <scope>:<domain>:<id>[:<subtype>].

TTL Policy

  • Security-sensitive values (sessions/OTP/tokens/rate limits) MUST expire.
  • Cache entries without TTL MUST be explicitly justified.

Invalidation

  • State-changing writes MUST invalidate or refresh affected keys.
  • Auth/session flows MUST revoke/delete keys on logout/revoke/consume.
  • Correctness-sensitive flows SHOULD prefer explicit invalidation (DEL).