redis_scan
Scan Redis keys safely using cursor-based SCAN, filtering by glob pattern and value type, with pagination support.
Instructions
Enumerate keys with cursor-based SCAN -- NEVER the O(N) KEYS command, so this is safe to run against a production instance with millions of keys (SCAN yields the event loop between batches). Returns up to REDIS_MAX_KEYS keys (default 1000) matching an optional glob match pattern (e.g. user:*, session:??). When more keys remain, truncated is true and cursor is non-'0' -- pass that cursor back to continue from where you left off. Optionally filter by value type (string/list/set/zset/hash/stream). Within one call duplicate keys are removed; across a resumed scan a key may reappear (SCAN's guarantee is no key present for the whole scan is missed, not that none repeats).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | Filter to keys of this value type (uses SCAN's TYPE option). | |
| count | No | COUNT hint per SCAN iteration (default REDIS_SCAN_COUNT=100). Higher = fewer round-trips, but very high values increase per-iteration event-loop hold time on large keyspaces -- the small-batch yield is this module's core safety property for production instances. | |
| match | No | Glob pattern to match keys (e.g. `user:*`). Omit to scan all keys. | |
| cursor | No | SCAN cursor to resume from. Start (and default) is '0'. | 0 |