Yes, you can establish a connection to tikv://192.168.69.31:2379 and then use the prefix to scan values from multiple prefixes at once. However, you need to use the tikv-go client’s RawScan method to scan the values, and specify the range of keys that you want to scan using the prefix.
Here is an example code snippet that demonstrates how to scan values from multiple prefixes using the RawScan method:
import (
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/config"
)
// create a TiKV client
pdAddrs := []string{"192.168.69.31:2379"}
cfg := config.Default()
cfg.PDAddrs = pdAddrs
client, err := tikv.NewRawKVClient(context.Background(), pdAddrs, cfg)
if err != nil {
// handle error
}
// specify the range of keys to scan using the prefix
startKey := []byte("f5")
endKey := []byte("f6")
// scan the values using the RawScan method
iter, err := client.RawScan(context.Background(), startKey, endKey)
if err != nil {
// handle error
}
defer iter.Close()
// iterate over the values and do something with them
for iter.Valid() {
key := iter.Key()
value := iter.Value()
// do something with the key and value
iter.Next()
}
In this example, we create a tikv-go client and specify the PD address. Then, we use the RawScan method to scan the values from the range of keys that start with the prefix “f5” and end with the prefix “f6”. Finally, we iterate over the values and do something with them.
Please note that the RawScan method returns all the key-value pairs in the specified range, regardless of the prefix. Therefore, you need to filter the key-value pairs that belong to the prefixes that you are interested in.