https://github.com/gbrlsnchs/redis
Redis client for Go (or Golang)
https://github.com/gbrlsnchs/redis
client go golang redis
Last synced: about 2 months ago
JSON representation
Redis client for Go (or Golang)
- Host: GitHub
- URL: https://github.com/gbrlsnchs/redis
- Owner: gbrlsnchs
- License: mit
- Created: 2018-05-09T16:24:44.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-10T16:23:53.000Z (over 7 years ago)
- Last Synced: 2025-12-13T09:52:29.540Z (6 months ago)
- Topics: client, go, golang, redis
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# redis (Redis client for Go)
[](https://travis-ci.org/gbrlsnchs/redis)
[](https://sourcegraph.com/github.com/gbrlsnchs/redis?badge)
[](https://godoc.org/github.com/gbrlsnchs/redis)
[](https://golang.org/doc/go1.10)
## About
This package is a simple [Redis](https://redis.io) client for [Go](https://golang.org). It is context-aware and uses a resizable connection pool internally.
## Usage
Full documentation [here](https://godoc.org/github.com/gbrlsnchs/redis).
### Installing
#### Go 1.10
`vgo get -u github.com/gbrlsnchs/redis`
#### Go 1.11 or after
`go get -u github.com/gbrlsnchs/redis`
### Importing
```go
import (
// ...
"github.com/gbrlsnchs/redis"
)
```
### Pinging the database
```go
db, err := redis.Open(":6379")
if err != nil {
// handle error
}
if _, err = db.Ping(); err != nil {
// handle error
}
```
### Configuring the connection pool
```go
db, err := redis.Open(":6379")
if err != nil {
// handle error
}
db.SetMaxIdleConns(20) // reuses up to 20 connections without closing them
db.SetMaxOpenConns(45) // opens up to 45 connections (20 remain open), otherwise waits
```
### Sending commands
```go
r, err := db.Send("SET", "foo", 1)
if err != nil {
// handle error
}
fmt.Println(r.String()) // prints "OK"
fmt.Println(r.IsOK()) // prints "true"
if r, err = db.Send("GET", "foo"); err != nil {
// handle error
}
fmt.Println(r.Int64()) // prints "1"
```
## Contributing
### How to help
- For bugs and opinions, please [open an issue](https://github.com/gbrlsnchs/connpool/issues/new)
- For pushing changes, please [open a pull request](https://github.com/gbrlsnchs/connpool/compare)