SCAN

Iterates over keys using a cursor and a pattern filter.

Keys & expiration · Example verified

Syntax covered here

SCAN cursor MATCH pattern COUNT count

Start at cursor 0 and keep following returned cursors, including through empty batches, until the cursor returns to 0. The verified traversal required 64 iterations despite a large COUNT value.

Tested example & replies

Requests below run in order against an empty database. Each connection authenticates with the fixture password first. Quoted values are strings; null is a nil reply; arrays preserve RESP order.

# connection: default
> SET sample value
"OK"
# default: SCAN cursor loop (64 requests)
> SCAN 0 MATCH sam* COUNT 1000
["288230376151711744",[]]
# Continue with each returned cursor until it is "0".
# 62 intermediate replies in the downloadable receipt.
> SCAN 18158513697557839872 MATCH sam* COUNT 1000
["0",[]]
# Combined keys: ["sample"]
Verification scope: the argument forms, setup and assertions shown here. These examples do not establish support for unlisted options or deployment modes. Run your application tests with your data and client.
Test environment & reproducible evidence

Verified: 2026-09-21T11:06:06Z · Docker / Linux aarch64 · lavik 0.1.0-beta.1

Storage & connection: io_uring · temporary file, 2 workers, standalone, plaintext TCP, password authentication. This test does not measure NVMe performance.

Pinned source: 3955b98d43b312324aa8d52775df52cfb111c0d0

Binary SHA-256: 8306b37ddf05023f85166a6aa2192b7084757e8defd342b602e6470244aca887

Image: sha256:af0cfb11b78f184cb6cc49a774a49dc97a8e43a0bd3f4d63d83c8c9ef3282d6e

Full test receipt · Executable tests

Lavik command registry · Valkey counterpart (support may differ)