Answer the question
In order to leave comments, you need to log in
Am I using redis scan correctly? Or is the problem somewhere else?
redisClient.FlushDb()
for i := 0; i < 33; i++ {
err := redisClient.Set(fmt.Sprintf("key%d", i), "value", 0).Err()
if err != nil {
panic(err)
}
}
var cursor int64
var n int
for {
var keys []string
var err error
cursor, keys, err = redisClient.Scan(cursor, "", 10).Result()
if err != nil {
panic(err)
}
n += len(keys)
if cursor == 0 {
break
}
}
fmt.Printf("found %d keys\n", n)
// Output: found 33 keys
Answer the question
In order to leave comments, you need to log in
compile in pieces
something you obviously do not finish speaking
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question