Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resume enumerate key from last breakpoint? #2717

Closed
maomaomqiu opened this issue May 20, 2024 · 2 comments
Closed

How to resume enumerate key from last breakpoint? #2717

maomaomqiu opened this issue May 20, 2024 · 2 comments

Comments

@maomaomqiu
Copy link

Hi,
I am working on a task to purge persistent keys generated due to legacy bugs, below is main logic

...
(1) var keys = server.KeysAsync(pattern: pattern).GetAsyncEnumerator();

(2) batchExpireBuffer.Add(keys.Current.ToString()); 

(3) every 50 keys, BatchSetExpire(batchExpireBuffer)

Consider the total amount of keys need purge is huge (could up to 50 million),
We start enumerate from key0, suppose the collection for enumerator is {key0, key1, key2, ...}, once there are exception happened in (1) - (3), and before exception happened, we already finished key1, is there any way to get some information, so that when run next job, we can start from key2?

@maomaomqiu
Copy link
Author

I have thought about a way, log cursor value and pageoffset when exception happened

@maomaomqiu
Copy link
Author

var currentKey = keys.Current.ToString();
IScanningCursor cursor = (IScanningCursor)keys;
long cursorvalue = cursor.Cursor;
long pageoffset = cursor.PageOffset;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant