Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gbrlsnchs/redis
Redis client for Go (or Golang)
https://github.com/gbrlsnchs/redis
client go golang redis
Last synced: 10 days 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-10T16:23:53.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T05:06:12.517Z (5 months ago)
- Topics: client, go, golang, redis
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 2
- 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)
[![Build Status](https://travis-ci.org/gbrlsnchs/redis.svg?branch=master)](https://travis-ci.org/gbrlsnchs/redis)
[![Sourcegraph](https://sourcegraph.com/github.com/gbrlsnchs/redis/-/badge.svg)](https://sourcegraph.com/github.com/gbrlsnchs/redis?badge)
[![GoDoc](https://godoc.org/github.com/gbrlsnchs/redis?status.svg)](https://godoc.org/github.com/gbrlsnchs/redis)
[![Minimal Version](https://img.shields.io/badge/minimal%20version-go1.10%2B-5272b4.svg)](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)