Keys and Naming

View saved

Keys are strings

Choose readable names. A common pattern is object:id:field or app:env:purpose.

SET session:abc123 "{...}"
SET cache:product:42 "{...}"

Why prefixes help

  • Separate features: cache:, session:, lock:
  • Make SCAN patterns useful
  • Reduce collisions between teammates' keys

Check type and existence

Know what lives at a key before you overwrite it.

EXISTS cache:product:42
TYPE cache:product:42
TTL cache:product:42

Rename carefully

RENAME moves a key. Prefer deleting and rewriting only when you understand the impact on clients.

RENAME cache:product:42 cache:product:42:v2

Comments

One comment per signed-in account. Comments are saved with this page’s URL.