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

Function ExampleClient

example_test.go:133–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131}
132
133func ExampleClient() {
134 err := rdb.Set(ctx, "key", "value", 0).Err()
135 if err != nil {
136 panic(err)
137 }
138
139 val, err := rdb.Get(ctx, "key").Result()
140 if err != nil {
141 panic(err)
142 }
143 fmt.Println("key", val)
144
145 val2, err := rdb.Get(ctx, "missing_key").Result()
146 if err == redis.Nil {
147 fmt.Println("missing_key does not exist")
148 } else if err != nil {
149 panic(err)
150 } else {
151 fmt.Println("missing_key", val2)
152 }
153 // Output: key value
154 // missing_key does not exist
155}
156
157func ExampleConn_name() {
158 conn := rdb.Conn()

Callers

nothing calls this directly

Calls 4

ErrMethod · 0.65
SetMethod · 0.65
ResultMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected