()
| 311 | } |
| 312 | |
| 313 | func ExampleClient_timeseries_query_multi() { |
| 314 | ctx := context.Background() |
| 315 | |
| 316 | rdb := redis.NewClient(&redis.Options{ |
| 317 | Addr: "localhost:6379", |
| 318 | Password: "", // no password set |
| 319 | DB: 0, // use default DB |
| 320 | }) |
| 321 | |
| 322 | // REMOVE_START |
| 323 | // make sure we are working with fresh database |
| 324 | rdb.FlushDB(ctx) |
| 325 | rdb.Del(ctx, "rg:2", "rg:3", "rg:4") |
| 326 | // REMOVE_END |
| 327 | |
| 328 | // STEP_START query_multi |
| 329 | // Create three new "rg:" time series (two in the US |
| 330 | // and one in the UK, with different units) and add some |
| 331 | // data points. |
| 332 | res20, err := rdb.TSCreateWithArgs(ctx, "rg:2", &redis.TSOptions{ |
| 333 | Labels: map[string]string{"location": "us", "unit": "cm"}, |
| 334 | }).Result() |
| 335 | if err != nil { |
| 336 | panic(err) |
| 337 | } |
| 338 | |
| 339 | fmt.Println(res20) // >>> OK |
| 340 | |
| 341 | res21, err := rdb.TSCreateWithArgs(ctx, "rg:3", &redis.TSOptions{ |
| 342 | Labels: map[string]string{"location": "us", "unit": "in"}, |
| 343 | }).Result() |
| 344 | if err != nil { |
| 345 | panic(err) |
| 346 | } |
| 347 | |
| 348 | fmt.Println(res21) // >>> OK |
| 349 | |
| 350 | res22, err := rdb.TSCreateWithArgs(ctx, "rg:4", &redis.TSOptions{ |
| 351 | Labels: map[string]string{"location": "uk", "unit": "mm"}, |
| 352 | }).Result() |
| 353 | if err != nil { |
| 354 | panic(err) |
| 355 | } |
| 356 | |
| 357 | fmt.Println(res22) // >>> OK |
| 358 | |
| 359 | res23, err := rdb.TSMAdd(ctx, [][]interface{}{ |
| 360 | {"rg:2", 0, 1.8}, |
| 361 | {"rg:3", 0, 0.9}, |
| 362 | {"rg:4", 0, 25}, |
| 363 | }).Result() |
| 364 | if err != nil { |
| 365 | panic(err) |
| 366 | } |
| 367 | |
| 368 | fmt.Println(res23) // >>> [0 0 0] |
| 369 | |
| 370 | res24, err := rdb.TSMAdd(ctx, [][]interface{}{ |
nothing calls this directly
no test coverage detected