| 96 | } |
| 97 | |
| 98 | func ExampleClient_mset() { |
| 99 | ctx := context.Background() |
| 100 | |
| 101 | rdb := redis.NewClient(&redis.Options{ |
| 102 | Addr: "localhost:6379", |
| 103 | Password: "", // no password docs |
| 104 | DB: 0, // use default DB |
| 105 | }) |
| 106 | |
| 107 | // REMOVE_START |
| 108 | // start with fresh database |
| 109 | rdb.FlushDB(ctx) |
| 110 | rdb.Del(ctx, "bike:1", "bike:2", "bike:3") |
| 111 | // REMOVE_END |
| 112 | |
| 113 | // STEP_START mset |
| 114 | res6, err := rdb.MSet(ctx, "bike:1", "Deimos", "bike:2", "Ares", "bike:3", "Vanth").Result() |
| 115 | |
| 116 | if err != nil { |
| 117 | panic(err) |
| 118 | } |
| 119 | |
| 120 | fmt.Println(res6) // >>> OK |
| 121 | |
| 122 | res7, err := rdb.MGet(ctx, "bike:1", "bike:2", "bike:3").Result() |
| 123 | |
| 124 | if err != nil { |
| 125 | panic(err) |
| 126 | } |
| 127 | |
| 128 | fmt.Println(res7) // >>> [Deimos Ares Vanth] |
| 129 | // STEP_END |
| 130 | |
| 131 | // Output: |
| 132 | // OK |
| 133 | // [Deimos Ares Vanth] |
| 134 | } |
| 135 | |
| 136 | func ExampleClient_incr() { |
| 137 | ctx := context.Background() |