...
1
2
3 package example_commands_test
4
5 import (
6 "context"
7 "fmt"
8
9 "github.com/redis/go-redis/v9"
10 )
11
12
13
14 func ExampleClient_cmd_flushall() {
15 ctx := context.Background()
16
17 rdb := redis.NewClient(&redis.Options{
18 Addr: "localhost:6379",
19 Password: "",
20 DB: 0,
21 })
22
23
24
25
26 rdb.FlushDB(ctx)
27 rdb.Set(ctx, "testkey1", "1", 0)
28 rdb.Set(ctx, "testkey2", "2", 0)
29 rdb.Set(ctx, "testkey3", "3", 0)
30
31 flushAllResult1, err := rdb.FlushAll(ctx).Result()
32
33 if err != nil {
34 panic(err)
35 }
36
37 fmt.Println(flushAllResult1)
38
39 flushAllResult2, err := rdb.Keys(ctx, "*").Result()
40
41 if err != nil {
42 panic(err)
43 }
44
45 fmt.Println(flushAllResult2)
46
47
48
49
50
51 }
52
53 func ExampleClient_cmd_info() {
54 ctx := context.Background()
55
56 rdb := redis.NewClient(&redis.Options{
57 Addr: "localhost:6379",
58 Password: "",
59 DB: 0,
60 })
61
62
63 infoResult, err := rdb.Info(ctx).Result()
64
65 if err != nil {
66 panic(err)
67 }
68
69
70
71 fmt.Println(infoResult[:8])
72
73
74
75
76 }
77
View as plain text