MCPcopy
hub / github.com/redis/go-redis / ExampleClient_xgroupcreate

Function ExampleClient_xgroupcreate

doctests/stream_tutorial_test.go:479–521  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

477}
478
479func ExampleClient_xgroupcreate() {
480 ctx := context.Background()
481
482 rdb := redis.NewClient(&redis.Options{
483 Addr: "localhost:6379",
484 Password: "", // no password docs
485 DB: 0, // use default DB
486 })
487
488 // REMOVE_START
489 // start with fresh database
490 rdb.FlushDB(ctx)
491 rdb.Del(ctx, "race:france")
492 // REMOVE_END
493
494 _, err := rdb.XAdd(ctx, &redis.XAddArgs{
495 Stream: "race:france",
496 Values: map[string]interface{}{
497 "rider": "Castilla",
498 "speed": 30.2,
499 "position": 1,
500 "location_id": 1,
501 },
502 ID: "1692632086370-0",
503 }).Result()
504
505 if err != nil {
506 panic(err)
507 }
508
509 // STEP_START xgroup_create
510 res19, err := rdb.XGroupCreate(ctx, "race:france", "france_riders", "$").Result()
511
512 if err != nil {
513 panic(err)
514 }
515
516 fmt.Println(res19) // >>> OK
517 // STEP_END
518
519 // Output:
520 // OK
521}
522
523func ExampleClient_xgroupcreatemkstream() {
524 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

FlushDBMethod · 0.65
DelMethod · 0.65
ResultMethod · 0.65
XAddMethod · 0.65
XGroupCreateMethod · 0.65

Tested by

no test coverage detected