SCAN
Iterates over keys using a cursor and a pattern filter.
Keys & expiration · Example verified
Syntax covered here
SCAN cursor MATCH pattern COUNT countStart 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"]