()
| 115 | } |
| 116 | |
| 117 | func ExampleClient_num() { |
| 118 | ctx := context.Background() |
| 119 | |
| 120 | rdb := redis.NewClient(&redis.Options{ |
| 121 | Addr: "localhost:6379", |
| 122 | Password: "", // no password docs |
| 123 | DB: 0, // use default DB |
| 124 | }) |
| 125 | |
| 126 | // REMOVE_START |
| 127 | // start with fresh database |
| 128 | rdb.FlushDB(ctx) |
| 129 | rdb.Del(ctx, "crashes") |
| 130 | // REMOVE_END |
| 131 | |
| 132 | // STEP_START num |
| 133 | res7, err := rdb.JSONSet(ctx, "crashes", "$", 0).Result() |
| 134 | |
| 135 | if err != nil { |
| 136 | panic(err) |
| 137 | } |
| 138 | |
| 139 | fmt.Println(res7) // >>> OK |
| 140 | |
| 141 | res8, err := rdb.JSONNumIncrBy(ctx, "crashes", "$", 1).Result() |
| 142 | |
| 143 | if err != nil { |
| 144 | panic(err) |
| 145 | } |
| 146 | |
| 147 | fmt.Println(res8) // >>> [1] |
| 148 | |
| 149 | res9, err := rdb.JSONNumIncrBy(ctx, "crashes", "$", 1.5).Result() |
| 150 | |
| 151 | if err != nil { |
| 152 | panic(err) |
| 153 | } |
| 154 | |
| 155 | fmt.Println(res9) // >>> [2.5] |
| 156 | |
| 157 | res10, err := rdb.JSONNumIncrBy(ctx, "crashes", "$", -0.75).Result() |
| 158 | |
| 159 | if err != nil { |
| 160 | panic(err) |
| 161 | } |
| 162 | |
| 163 | fmt.Println(res10) // >>> [1.75] |
| 164 | // STEP_END |
| 165 | |
| 166 | // Output: |
| 167 | // OK |
| 168 | // [1] |
| 169 | // [2.5] |
| 170 | // [1.75] |
| 171 | } |
| 172 | |
| 173 | func ExampleClient_arr() { |
| 174 | ctx := context.Background() |
nothing calls this directly
no test coverage detected
searching dependent graphs…