Skip to main content

SCAN

Note

Official reference: SCAN.

Read one batch of key names and its continuation cursor.

Syntax

SCAN cursor [MATCH pattern] [COUNT count] [TYPE type]

Start with cursor 0. MATCH filters names, COUNT hints at scan work, and TYPE accepts Redis type names such as string, hash, list, set and zset.

Results

ReturnRowsContent
ResultSetmultipleCURSOR field, STRING type
KEY field, STRING type
Caution

The cursor is attached to result rows, so empty batches lose the continuation cursor. COUNT also caps returned rows and may truncate a batch. Do not use this path for complete traversal. Use KEYS for pattern-based key retrieval, or a Redis client to manage cursors yourself.

Example

SET demo:message hello
SCAN 0 MATCH demo:* COUNT 10 TYPE string