Redis Advanced icon

Redis Advanced

Get, send and update data in Redis with enhanced operations

Scan

AI-generated

Summary

Scan keys incrementally in Redis starting from a specified cursor, optionally matching a key pattern and limiting the count of keys returned per call.

Inputs

  • Cursor — Cursor position for scanning; use 0 to start a new scan iteration.
  • Pattern — Glob-style pattern to match keys against; defaults to '*' to match all keys.
  • Count — Approximate number of keys to return in this scan iteration; defaults to 10.

Output shape

A single JSON object containing the 'cursor' for the next scan position and an array of matched 'keys'.

The scan command is incremental and production-safe for large datasets. The returned cursor must be used in subsequent calls to continue scanning until the cursor returns to 0, indicating the complete iteration over the keys.

Discussion