kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

Optimize the implementation of command RANDOMKEY

Open PragmaTwice opened this issue 2 years ago • 18 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Motivation

Currently the result key of command RANDOMKEY is not randomized enough, so we'd better do some research and optimize it.

Solution

No response

Are you willing to submit a PR?

  • [ ] I'm willing to submit a PR!

PragmaTwice avatar Aug 09 '23 12:08 PragmaTwice

I'll try this.

Yangsx-1 avatar Aug 10 '23 07:08 Yangsx-1

@Yangsx-1 Assigned.

torwig avatar Aug 10 '23 07:08 torwig

Can we add a random_scan function? This function will select the key at random intervals during the scan, after scan we can randomly select keys from the scan result. This may be more random. @PragmaTwice @git-hulk @torwig

Yangsx-1 avatar Sep 19 '23 07:09 Yangsx-1

Could you give more detailed design of it? I cannot get your point well.

Besides, I think one possible way is to add more random cursors, and select one of them each time.

PragmaTwice avatar Sep 20 '23 03:09 PragmaTwice

Could you give more detailed design of it? I cannot get your point well.

Besides, I think one possible way is to add more random cursors, and select one of them each time.

Oh, i mean, we can add a random interval in the iteration of scaning.

For example, the scan result may be 1 2 3 4 5 6 now, after add a random interval, the result may be 1 3 6 9 10 12 rather than pure sequential scanning. And we can select a key from the result of random scan.

Yangsx-1 avatar Sep 20 '23 04:09 Yangsx-1