Created
November 1, 2022 09:45
-
-
Save Queetinliu/884a0ee8679cb060e6931be203cc7cbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"github.com/go-redis/redis/v9" | |
) | |
var ctx = context.Background() | |
func main() { | |
rdb := redis.NewFailoverClient(&redis.FailoverOptions{ | |
MasterName: "mymaster", | |
SentinelAddrs: []string{"10.66.0.40:26379", "10.66.0.41:26379", | |
"10.66.0.42:26379", "10.66.0.44:26379"}, | |
Password: "", | |
PoolSize: 100, | |
MaxRetries: 3, | |
DB: 0, | |
SentinelPassword: "", | |
}) | |
i := 0 | |
for true { | |
key := fmt.Sprintf("key%d", i) | |
value := fmt.Sprintf("value%d", i) | |
err := rdb.Set(ctx, key, value, 0).Err() | |
if err != nil { | |
fmt.Println(err) | |
} else { | |
fmt.Printf("sucessly write %s %s to redis", key, value) | |
i++ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment