| 307 | } |
| 308 | |
| 309 | func ExampleClient_racefrance2() { |
| 310 | ctx := context.Background() |
| 311 | |
| 312 | rdb := redis.NewClient(&redis.Options{ |
| 313 | Addr: "localhost:6379", |
| 314 | Password: "", // no password docs |
| 315 | DB: 0, // use default DB |
| 316 | }) |
| 317 | |
| 318 | // REMOVE_START |
| 319 | // start with fresh database |
| 320 | rdb.FlushDB(ctx) |
| 321 | rdb.Del(ctx, "race:france") |
| 322 | // REMOVE_END |
| 323 | |
| 324 | _, err := rdb.XAdd(ctx, &redis.XAddArgs{ |
| 325 | Stream: "race:france", |
| 326 | Values: map[string]interface{}{ |
| 327 | "rider": "Castilla", |
| 328 | "speed": 30.2, |
| 329 | "position": 1, |
| 330 | "location_id": 1, |
| 331 | }, |
| 332 | ID: "1692632086370-0", |
| 333 | }).Result() |
| 334 | |
| 335 | if err != nil { |
| 336 | panic(err) |
| 337 | } |
| 338 | |
| 339 | _, err = rdb.XAdd(ctx, &redis.XAddArgs{ |
| 340 | Stream: "race:france", |
| 341 | Values: map[string]interface{}{ |
| 342 | "rider": "Norem", |
| 343 | "speed": 28.8, |
| 344 | "position": 3, |
| 345 | "location_id": 1, |
| 346 | }, |
| 347 | ID: "1692632094485-0", |
| 348 | }).Result() |
| 349 | |
| 350 | if err != nil { |
| 351 | panic(err) |
| 352 | } |
| 353 | |
| 354 | _, err = rdb.XAdd(ctx, &redis.XAddArgs{ |
| 355 | Stream: "race:france", |
| 356 | Values: map[string]interface{}{ |
| 357 | "rider": "Prickett", |
| 358 | "speed": 29.7, |
| 359 | "position": 2, |
| 360 | "location_id": 1, |
| 361 | }, |
| 362 | ID: "1692632102976-0", |
| 363 | }).Result() |
| 364 | |
| 365 | if err != nil { |
| 366 | panic(err) |