Repository navigation
Add SCAN incremental cursor iteration feature - #347
Merged
Merged
Conversation
Add --scan-incremental-iteration and --scan-incremental-max-iterations options that enable automatic cursor following for SCAN commands. When enabled, the tool sends the initial SCAN 0 command, extracts the cursor from each response, and sends continuation SCAN <cursor> commands until the cursor returns to 0 or max iterations is reached. Statistics are tracked separately for "SCAN 0" (initial) and "SCAN <cursor>" (continuation) commands in both stdout and JSON output. Includes 15 integration tests covering all SCAN option combinations (bare, MATCH, COUNT, TYPE, and combinations), error validation, request counting, and large keyspace (10K keys) scenarios. Co-Authored-By: Claude Opus 4.6 <[email protected]>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Collaborator
Author
|
cursor review |
SCAN incremental iteration is a single-endpoint feature (cluster mode is explicitly disallowed), so all tests should skip when running in cluster mode. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The iteration counter was incremented for every SCAN response including the initial SCAN 0, but max-iterations is documented as the maximum number of *continuation* SCANs. Now only continuation responses (ar->index == 1) increment the counter, so max-iterations=N yields exactly N continuations per cycle. Updated test_scan_incremental_max_iterations to assert exact counts: with max_iterations=3 and 40 requests, expect 10 initials + 30 continuations. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Collaborator
Author
|
cursor review |
…mand Other call sites check the return value and handle failure. Without the check, a parse failure would leave the continuation command with zero args, causing malformed RESP commands on every continuation attempt. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Collaborator
Author
|
cursor review. |
paulorsousa
approved these changes
Feb 25, 2026
2 tasks done
This was referenced Oct 14, 2026
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--scan-incremental-iterationand--scan-incremental-max-iterationsCLI options for automatic SCAN cursor following--command "SCAN 0 [MATCH pattern] [COUNT count] [TYPE type]", the tool extracts the cursor from each SCAN response and sends continuation commands until the cursor returns to 0 (or max iterations reached)Test plan
tests/test_scan.pycovering:make format-checkpasses on all modified C++ filesTEST=test_scan.py OSS_STANDALONE=1 ./tests/run_tests.sh— all 15 tests pass🤖 Generated with Claude Code
Note
Medium Risk
Touches core request generation/response parsing and arbitrary-command formatting to add SCAN stateful iteration; while guarded by strict option validation and extensive tests, bugs could affect benchmark correctness for arbitrary-command runs.
Overview
Adds an incremental SCAN cursor iteration mode for arbitrary commands via
--scan-incremental-iterationplus an optional--scan-incremental-max-iterationscap. When enabled, memtier automatically alternates between an initialSCAN 0 ...and continuationSCAN <cursor> ...requests by extracting the cursor from each response, resetting on errors or when the cursor/max-iteration threshold completes a cycle, and reporting stats separately for initial vs continuation SCANs.This introduces a new
__scan_cursor__placeholder/arg type for formatting and sending continuation commands, enforces runtime validation (pipeline must be 1, exactly oneSCANcommand, not cluster mode), updates bash completion and man page, and adds a comprehensivetests/test_scan.pyintegration suite validating stdout/JSON stats and error cases. Documentation inAGENTS.mdis also expanded with stricter CLI-option checklist and test/JSON validation guidance.Written by Cursor Bugbot for commit 61efe3d. This will update automatically on new commits. Configure here.