Redis Cheat Sheet/List keys by pattern

Find matching keys. Use only on small datasets.

Section: Keys and expiration

List keys by pattern

bash
bash
KEYS user:*
Explanation

Prefer SCAN in production because KEYS blocks and can be expensive.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Keys and expiration
Check if key exists
Return how many specified keys exist.
OpenIn sheetbashsame section
Delete keys
Delete one or more keys.
OpenIn sheetbashsame section
Asynchronously delete keys
Delete keys lazily in background threads.
OpenIn sheetbashsame section
Inspect key type
Return the Redis type stored at a key.
OpenIn sheetbashsame section
Iterate keys incrementally
Cursor-based key iteration for production-safe scanning.
OpenIn sheetbashsame section
Return a random key
Pick an arbitrary key from the current DB.
OpenIn sheetbashsame section