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

Function ExampleClient_mset

doctests/string_example_test.go:98–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96}
97
98func ExampleClient_mset() {
99 ctx := context.Background()
100
101 rdb := redis.NewClient(&redis.Options{
102 Addr: "localhost:6379",
103 Password: "", // no password docs
104 DB: 0, // use default DB
105 })
106
107 // REMOVE_START
108 // start with fresh database
109 rdb.FlushDB(ctx)
110 rdb.Del(ctx, "bike:1", "bike:2", "bike:3")
111 // REMOVE_END
112
113 // STEP_START mset
114 res6, err := rdb.MSet(ctx, "bike:1", "Deimos", "bike:2", "Ares", "bike:3", "Vanth").Result()
115
116 if err != nil {
117 panic(err)
118 }
119
120 fmt.Println(res6) // >>> OK
121
122 res7, err := rdb.MGet(ctx, "bike:1", "bike:2", "bike:3").Result()
123
124 if err != nil {
125 panic(err)
126 }
127
128 fmt.Println(res7) // >>> [Deimos Ares Vanth]
129 // STEP_END
130
131 // Output:
132 // OK
133 // [Deimos Ares Vanth]
134}
135
136func ExampleClient_incr() {
137 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

FlushDBMethod · 0.65
DelMethod · 0.65
ResultMethod · 0.65
MSetMethod · 0.65
MGetMethod · 0.65

Tested by

no test coverage detected