StackExchange / StackExchange/StackExchange.Redis

Resumable scan through keys

Open
#2,425 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.2k
Forks
1.6k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Hi, I am trying to process keys on server in this batch pattern.

var cursor = 0;
do
{
    var keyBatch = await GetKeysAsync(cursor);
    foreach (var key in keyBatch)
    {
        ProcessKey(key);
    }
    cursor = keyBatch.NextCursor;
} while (cursor != 0);

How can I achieve this behaviour using IServer and IScanningCursor? This does not work.

var cursor = 0L;
do
{
    var counter = 0;
    var keys = server.KeysAsync(1, "user:*", 1000, cursor);
    await foreach (var key in keys)
    {
        counter++;
    }
    Console.WriteLine($"{cursor}, {counter}");

    cursor = ((IScanningCursor) keys).Cursor;
} while (cursor != 0);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the IServer.KeysAsync entry point and the IScanningCursor interface mentioned in the examples, then trace how the cursor is exposed after asynchronous enumeration. Reproduce the batch loop against Redis and compare the observed cursor with the expected continuation behavior; done means the intended resumable scan behavior is established or the discrepancy is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
api, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.