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

Function ExampleClient_raceitaly

doctests/stream_tutorial_test.go:661–1037  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

659}
660
661func ExampleClient_raceitaly() {
662 ctx := context.Background()
663
664 rdb := redis.NewClient(&redis.Options{
665 Addr: "localhost:6379",
666 Password: "", // no password docs
667 DB: 0, // use default DB
668 })
669
670 // REMOVE_START
671 // start with fresh database
672 rdb.FlushDB(ctx)
673 rdb.Del(ctx, "race:italy")
674 rdb.XGroupDestroy(ctx, "race:italy", "italy_riders")
675 // REMOVE_END
676
677 _, err := rdb.XGroupCreateMkStream(ctx,
678 "race:italy", "italy_riders", "$",
679 ).Result()
680
681 if err != nil {
682 panic(err)
683 }
684
685 _, err = rdb.XAdd(ctx, &redis.XAddArgs{
686 Stream: "race:italy",
687 Values: map[string]interface{}{"rider": "Castilla"},
688 ID: "1692632639151-0",
689 }).Result()
690
691 if err != nil {
692 panic(err)
693 }
694
695 _, err = rdb.XAdd(ctx, &redis.XAddArgs{
696 Stream: "race:italy",
697 Values: map[string]interface{}{"rider": "Royce"},
698 ID: "1692632647899-0",
699 }).Result()
700
701 if err != nil {
702 panic(err)
703 }
704
705 _, err = rdb.XAdd(ctx, &redis.XAddArgs{
706 Stream: "race:italy",
707 Values: map[string]interface{}{"rider": "Sam-Bodden"},
708 ID: "1692632662819-0",
709 }).Result()
710
711 if err != nil {
712 panic(err)
713 }
714
715 _, err = rdb.XAdd(ctx, &redis.XAddArgs{
716 Stream: "race:italy",
717 Values: map[string]interface{}{"rider": "Prickett"},
718 ID: "1692632670501-0",

Callers

nothing calls this directly

Calls 15

UNUSEDFunction · 0.85
FlushDBMethod · 0.65
DelMethod · 0.65
XGroupDestroyMethod · 0.65
ResultMethod · 0.65
XGroupCreateMkStreamMethod · 0.65
XAddMethod · 0.65
XReadGroupMethod · 0.65
XAckMethod · 0.65
XPendingMethod · 0.65
XPendingExtMethod · 0.65
XRangeMethod · 0.65

Tested by

no test coverage detected