7
7
8
8
> :heart : [ ** Uptrace.dev** - distributed traces, logs, and errors in one place] ( https://uptrace.dev )
9
9
10
- - [ Docs] ( https://redis.uptrace.dev )
10
+ - Join [ Discord] ( https://discord.gg/rWtp5Aj ) to ask questions.
11
+ - [ Documentation] ( https://redis.uptrace.dev )
11
12
- [ Reference] ( https://pkg.go.dev/github.com/go-redis/redis/v8?tab=doc )
12
13
- [ Examples] ( https://pkg.go.dev/github.com/go-redis/redis/v8?tab=doc#pkg-examples )
13
14
- [ RealWorld example app] ( https://github.com/uptrace/go-treemux-realworld-example-app )
14
- - Join [ Discord] ( https://discord.gg/rWtp5Aj ) to ask questions.
15
15
16
16
## Ecosystem
17
17
40
40
41
41
## Installation
42
42
43
- go-redis requires a Go version with [ Modules] ( https://github.com/golang/go/wiki/Modules ) support and
44
- uses import versioning. So please make sure to initialize a Go module before installing go-redis:
43
+ go-redis supports 2 last Go versions and requires a Go version with
44
+ [ modules] ( https://github.com/golang/go/wiki/Modules ) support. So make sure to initialize a Go
45
+ module:
45
46
46
47
``` shell
47
48
go mod init github.com/my/repo
48
- go get github.com/go-redis/redis/v8
49
49
```
50
50
51
- Import :
51
+ And then install go-redis (note _ v8 _ in the import; omitting it is a popular mistake) :
52
52
53
- ``` go
54
- import " github.com/go-redis/redis/v8"
53
+ ``` shell
54
+ go get github.com/go-redis/redis/v8
55
55
```
56
56
57
57
## Quickstart
@@ -64,24 +64,13 @@ import (
64
64
65
65
var ctx = context.Background ()
66
66
67
- func ExampleNewClient () {
68
- rdb := redis.NewClient (&redis.Options {
69
- Addr: " localhost:6379" ,
70
- Password: " " , // no password set
71
- DB: 0 , // use default DB
72
- })
73
-
74
- pong , err := rdb.Ping (ctx).Result ()
75
- fmt.Println (pong, err)
76
- // Output: PONG <nil>
77
- }
78
-
79
67
func ExampleClient () {
80
68
rdb := redis.NewClient (&redis.Options {
81
69
Addr: " localhost:6379" ,
82
70
Password: " " , // no password set
83
71
DB: 0 , // use default DB
84
72
})
73
+
85
74
err := rdb.Set (ctx, " key" , " value" , 0 ).Err ()
86
75
if err != nil {
87
76
panic (err)
@@ -106,11 +95,6 @@ func ExampleClient() {
106
95
}
107
96
```
108
97
109
- ## Howto
110
-
111
- Please go through [ examples] ( https://pkg.go.dev/github.com/go-redis/redis/v8?tab=doc#pkg-examples )
112
- to get an idea how to use this package.
113
-
114
98
## Look and feel
115
99
116
100
Some corner cases:
0 commit comments