Skip to content

How to do a SCAN? #348

Answered by rueian
JeffBNimble asked this question in Q&A
Aug 26, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @JeffBNimble,

Rueidis doesn't do the iteration. How to do the iteration is up to you. Here is an example for you to reference:

rueidis/rueidis_test.go

Lines 369 to 385 in 6556f2f

func ExampleClient_scan() {
client, err := NewClient(ClientOption{InitAddress: []string{"127.0.0.1:6379"}})
if err != nil {
panic(err)
}
defer client.Close()
for _, c := range client.Nodes() { // loop over all your redis nodes
var scan ScanEntry
for more := true; more; more = scan.Cursor != 0 {
if scan, err = c.Do(context.Background(), c.B().Scan().Cursor(scan.Cursor).Build()).AsScanEntry(); err != nil {
panic(err)
}
fmt.Println(scan.E…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JeffBNimble
Comment options

Answer selected by JeffBNimble
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants