HIDE_END
()
| 12 | // HIDE_END |
| 13 | |
| 14 | func ExampleClient_cmd_flushall() { |
| 15 | ctx := context.Background() |
| 16 | |
| 17 | rdb := redis.NewClient(&redis.Options{ |
| 18 | Addr: "localhost:6379", |
| 19 | Password: "", // no password docs |
| 20 | DB: 0, // use default DB |
| 21 | }) |
| 22 | |
| 23 | // STEP_START flushall |
| 24 | // REMOVE_START |
| 25 | // make sure we are working with fresh database |
| 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 | // REMOVE_END |
| 31 | flushAllResult1, err := rdb.FlushAll(ctx).Result() |
| 32 | |
| 33 | if err != nil { |
| 34 | panic(err) |
| 35 | } |
| 36 | |
| 37 | fmt.Println(flushAllResult1) // >>> OK |
| 38 | |
| 39 | flushAllResult2, err := rdb.Keys(ctx, "*").Result() |
| 40 | |
| 41 | if err != nil { |
| 42 | panic(err) |
| 43 | } |
| 44 | |
| 45 | fmt.Println(flushAllResult2) // >>> [] |
| 46 | // STEP_END |
| 47 | |
| 48 | // Output: |
| 49 | // OK |
| 50 | // [] |
| 51 | } |
| 52 | |
| 53 | func ExampleClient_cmd_info() { |
| 54 | ctx := context.Background() |