Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hoisie/redis
A simple, powerful Redis client for Go
https://github.com/hoisie/redis
Last synced: 24 days ago
JSON representation
A simple, powerful Redis client for Go
- Host: GitHub
- URL: https://github.com/hoisie/redis
- Owner: hoisie
- License: mit
- Created: 2010-01-21T05:58:22.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2016-07-30T15:45:59.000Z (almost 8 years ago)
- Last Synced: 2024-02-15T07:32:09.725Z (4 months ago)
- Language: Go
- Homepage:
- Size: 781 KB
- Stars: 590
- Watchers: 33
- Forks: 235
- Open Issues: 15
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Lists
- awesome-cobol - redis - A simple, powerful Redis client for Cobol. (Database Drivers / Middlewares)
- awesome-go-storage - redis - A simple, powerful Redis client for Go. (Database Drivers)
- fucking-awesome-go - :octocat: redis - A simple, powerful Redis client for Go. :star: 503 :fork_and_knife: 171 (Database Drivers / Advanced Console UIs)
- awesome-go - redis - Simple, powerful Redis client for Go. (Database Drivers / Advanced Console UIs)
- awesome-go - redis - A simple, powerful Redis client for Go. (Database Drivers / Advanced Console UIs)
- awesome-stars - hoisie/redis - A simple, powerful Redis client for Go (Go)
- awesome-go - redis - A simple, powerful Redis client for Go. (Database Drivers / Advanced Console UIs)
- awesome-go - redis - Go语言实现的简单,功能强大的Redis客户端。 (<span id="数据库驱动-database-drivers">数据库驱动 Database Drivers</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go. - redis - Simple, powerful Redis client for Go. (Database Drivers / Advanced Console UIs)
- awesome-go-cn - redis - 简单、强大的 Redis 客户端 (数据库驱动 / 高级控制台界面)
- awesome-go-storage - redis - A simple, powerful Redis client for Go. (Database Drivers)
- awesome-go - redis - A simple, powerful Redis client for Go. (Database Drivers / Advanced Console UIs)
- awesome-go-cn - redis
- awesome-go - redis - 簡單、強大的 Redis 客戶端 (數據庫驅動 / 高級控制台界面)
- awesome-go - redis - A simple, powerful Redis client for Go - ★ 576 (Database Drivers)
- awesome-go2 - redis - Simple, powerful Redis client for Go. (Database Drivers / Advanced Console UIs)
- awesome-go - redis - A simple, powerful Redis client for Go. (Database Drivers / Advanced Console UIs)
README
## redis.go
redis.go is a client for the [redis](http://github.com/antirez/redis) key-value store.
Some features include:
* Designed for Redis 2.6.x.
* Support for all redis types - strings, lists, sets, sorted sets, and hashes
* Very simple usage
* Connection pooling ( with configurable size )
* Support for concurrent access
* Manages connections to the redis server, including dropped and timed out connections
* Marshaling/Unmarshaling go types to hashesThis library is stable and is used in production environments. However, some commands have not been tested as thoroughly as others. If you find any bugs please file an issue!
# Installation
Just run `go get github.com/hoisie/redis`
## Examples
Most of the examples connect to a redis database running in the default port -- 6379.
### Hello World example
```go
package mainimport "github.com/hoisie/redis"
func main() {
var client redis.Client
var key = "hello"
client.Set(key, []byte("world"))
val, _ := client.Get("hello")
println(key, string(val))
}
```### Strings
```go
var client redis.Client
client.Set("a", []byte("hello"))
val, _ := client.Get("a")
println(string(val))
client.Del("a")
```
### Lists
```go
var client redis.Client
vals := []string{"a", "b", "c", "d", "e"}
for _, v := range vals {
client.Rpush("l", []byte(v))
}
dbvals,_ := client.Lrange("l", 0, 4)
for i, v := range dbvals {
println(i,":",string(v))
}
client.Del("l")
```
### Publish/Subscribe
```go
sub := make(chan string, 1)
sub <- "foo"
messages := make(chan Message, 0)
go client.Subscribe(sub, nil, nil, nil, messages)time.Sleep(10 * 1000 * 1000)
client.Publish("foo", []byte("bar"))msg := <-messages
println("received from:", msg.Channel, " message:", string(msg.Message))close(sub)
close(messages)
```More examples coming soon. See `redis_test.go` for more usage examples.
## Commands not supported yet
* MULTI/EXEC/DISCARD/WATCH/UNWATCH
* SORT
* ZUNIONSTORE / ZINTERSTORE