Google Go Client and Connectors for Redis

Overview

Go-Redis

Go Clients and Connectors for Redis.

The initial release provides the interface and implementation supporting the (~) full set of current Redis commands using synchrnous call semantics. (Pipelines and asychronous goodness using the goroutines and channels is next.)

Hope to add rigorous tests as soon as I have a better understanding of the Go language tools. Same applies to the makefile.
Also am not sure regarding the efficiency of the implementation (for the obvious reasons), but definitely a goal is to make this a high performance connector.

structure

The code is consolidated into a single 'redis' package and various elements of it are usable independently (for example if you wish to roll your own API but want to use the raw bytes protocol handling aspects).

Compliance

Both Go and Redis are dynamic projects and present a challenge in fully covering the possible combinations in the wild. Given the release of Go 1, this project will focus on Go 1 based Redis compatibility; we'll deal with the far off prospect of renewed major weekly changes in Go if and when that arises.

Current status is compatible with Redis 2.4.n (2.4.9 tested) and Go 1. Redis feature set is not fully covered and is WIP.

(Always refer to compliance_note.txt for current (accurate) status for specific branches.)

Getting started:

Get, build, and startup Redis:

make
chmod +x redis-server
./redis-server redis.conf

Confirm:

alphazero[13]:entrevous$ telnet localhost 6379
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

PING
+PONG

INFO
$282
redis_version:1.07
arch_bits:32
uptime_in_seconds:72
uptime_in_days:0
connected_clients:1
connected_slaves:0
used_memory:295232
changes_since_last_save:1
bgsave_in_progress:0
last_save_time:1259873372
total_connections_received:4
total_commands_processed:5
role:master

QUIT
Connection closed by foreign host.
alphazero[14]:entrevous$ 

get, and install, Go-Redis

Go-Redis is built using the Go tool. The tool assumes the code will be in a folder $GOPATH/src/redis .

cd $GOPATH/src
git clone git://github.com/alphazero/Go-Redis.git redis
cd redis
go install

Confirm the install has created redis.a in your $GOPATH/pkg/ folder:

ls -l $GOPATH/pkg/"$GOOS"_"$GOARCH"/redis.a

e.g. on my Mac OS X (64b)

ls -l <my-gopath>/pkg/darwin_amd64

run the benchmarks

Basic benchmarks are in ~/bench. Use Go tool (go run ) to run the individual bench apps.

cd bench
# run the asyncbench.go 
go run asyncbench.go

examples

Ciao.go is a sort of hello world for redis and should get you started for the barebones necessities of getting a client and issuing commands.

cd examples
go run ciao.go
Comments
  • support latest version of go r60 (released 2011/09/07)

    support latest version of go r60 (released 2011/09/07)

    support latest version of go r60 (released 2011/09/07)

    Added goinstall instruction to readme.

    Removed a debug output.

    tkawachi: Changed a response type for KEYS to MULTI_BULK simonjefford hopefully, this will now work with goinstall

    opened by kpm 4
  • not usable with go get

    not usable with go get

    I know this project has a lot of followers, it would be great if it could be installed with go get. The best way to do this is probably by renaming the repository to 'redis'. I did this here: https://github.com/bpowers/redis For my own personal use.

    Thoughts?

    opened by bpowers 3
  • Support goinstall

    Support goinstall

    goinstall allows you to auto-install github repos. I'm new to Go so I'm not sure what the underlying problem is. This would make it easy for noobs like me to install and use your project quickly.

    http://golang.org/cmd/goinstall/

    > goinstall -u github.com/alphazero/Go-Redis
    goinstall: github.com/alphazero/Go-Redis: package has no files
    
    opened by mperham 2
  • GetResponse sometimes returns a NIL object

    GetResponse sometimes returns a NIL object

    I have a long-running web service that uses Go-Redis. Once on a while I get the following stack trace:

    SIGSEGV: segmentation violation Faulting address: 0x20 PC=0x40a44d

    redis·_connHdl·ServiceRequest+0x28b /home/mike/workspace/Go-Redis/src/pkg/redis/connection.go:263 redis·_connHdl·ServiceRequest(0x7947e1a0, 0x7fae, 0x4b5d60, 0x0, 0x785cd7d0, ...) redis·_syncClient·Llen+0xfc /home/mike/workspace/Go-Redis/src/pkg/redis/synchclient.go:442 redis·_syncClient·Llen(0x79479930, 0x7fae, 0x785d7ba0, 0x7fae, 0x16, ...)

    It seems that GetResponse in protocol.go sometimes returns a nil object. However, connection.go always assumes it's not nil. Perhaps a check should be added in connection.go that tests if the response is nil?

    defect duplicate 
    opened by hoisie 2
  • LREM command argument order

    LREM command argument order

    The LREM command of Redis server in version 5.0.3 expects three arguments in the order key count value. See the docs for more information.

    Currently, the commend seems to be implemented with the arguments in the wrong order (key value count) and therefore does not work.

    For replication of this problem try the following code:

    package main
    
    import (
    	"github.com/alphazero/go-redis"
    )
    
    func main() {
    	spec := redis.DefaultSpec().Host(redis.DefaultRedisHost).Port(redis.DefaultRedisPort).Password(redis.DefaultRedisPassword).Db(1)
    	client, err := redis.NewSynchClientWithSpec(spec)
    	if err != nil {
    		return
    	}
    
    	defer client.Quit()
    
    	client.Lpush("test", []byte("Test"))
    	client.Lpush("test", []byte("Test"))
    	client.Lpush("test", []byte("Test"))
    
    	removedItems, err := client.Lrem("test", []byte("test"), 0) // current implementation
    	// removedItems, err := client.Lrem("test", 0, []byte("test")) // Should be implemented like this
    	if err != nil {
    		println(err)
    	}
    }
    

    Thanks in advance for your help with this problem! schoeppi5

    opened by schoeppi5 1
  • Go Redis will get slow query (1 s) when application load is heavy

    Go Redis will get slow query (1 s) when application load is heavy

    I have a web API written in Go using Go redis. the API will connection to redis,fetch the newest 5 items in a 20-items list,do some iter computation,and reture the result. (I will use RPUSH to store the list )

    However,when a use http_load to run benchmark,the log shows that redis is slow. The slow rate is about 0.1%. Every time I run the benchmark,there will be slow log

    When I use Python script ,the redis response always in ms! How is that?

    the init connection code is as this:

    spec := redis.DefaultSpec().Host(host).Port(port).Db(db)
    conn, e := redis.NewAsynchClientWithSpec(spec)
    if e != nil {
        log.Fatal("Error creating client for worker: ", e)
        os.Exit(1)
    }
    

    And the Lrange code is as this:

    futureData,err = (*Redis).Lrange("my redis key",- 5,-1)
    timeout := 100*time.Millisecond
    t := time.Now()
    mydata,err,timedout  := futureData.TryGet(timeout)
    if time.Since(t) > time.Second {
        log.Println("slow redis query[fetch result]")
    }
    
    opened by Codefor 1
  • Simple change to the benchmark import description.

    Simple change to the benchmark import description.

    Quick change that allows the benchmark files to be run without modifying GOPATH. With this change it should be possible to run the following series of commands

    go get github.com/alphazero/Go-redis echo "requirepass go-redis" | redis-server - & for i in src/github.com/alphazero/Go-redis/bench/*.go ; do go run $i done kill %1

    The idea is to make it super simple to run.

    Tested using the above commands.

    opened by liquidgecka 1
  • Leave flag.Parse() to the main().

    Leave flag.Parse() to the main().

    Calling flag.Parse() in our init() inhibits others from using the flag module.

    All flag definitions must happen before flag.Parse() is called, and flag.Parse() can only effectively be called once. So a client pulling in Go-Redis also using the flag module would get an error of the form: flag provided but not defined: -the-client-app-flag

    We can't effectively coerce that flag.Parse() must happen, unless we use sync.Once to call it in our own API guarded by a call to flag.Parsed().

    opened by philpennock 1
  • Make package installable using

    Make package installable using "go get"

    Please make the package installable using "go get" instead of the manual steps described in the readme. The go tool is the standard way to download and install packages. It does not look like anything in your package should prevent the use the go tool for installation.

    opened by ghost 1
  • adds automatic connection reconnecting

    adds automatic connection reconnecting

    Adds reconnect() methods for connHdl and asyncConnHdl which get called when connHdl.ServiceRequest() or asyncConnHdl.QueueRequest() fail. Adds basic implementation of asyncConnHdl.disconnect().

    opened by wellle 0
  • Use of flags in init() short circuits argument parsing

    Use of flags in init() short circuits argument parsing

    calling flag.Parse() in init() breaks flags module

    $ cat test/test_redis.go package main import ( "fmt" "flag" redis "Go-Redis" ) func main() { var configfile string flag.StringVar(&configfile, "config", "/etc/config.ini", "configuration file") flag.Parse() fmt.Println("Config file", configfile)

    spec := redis.DefaultSpec()
    _ = spec
    

    --- output ---

    go run test/test_redis.go -config /etc/config.ini flag provided but not defined: -config Usage of /tmp/go-build929316002/command-line-arguments/_obj/a.out: -redis:d=false: debug flag for go-redis exit status 2

    opened by sigmonsays 1
  • confuse about description and example code in filte redis.go?

    confuse about description and example code in filte redis.go?

    Is there mismatch between description and code example? 1,From my understanding when introducing sync,async code is used,and introducing async,a old version async code is used.I can't find method "NewRedisPipeline(spec)".

    2, AsyncClient equals pipeline,right? and you didn't give a method named like "flush" or "batchCommit" for committing batched commands,the "futureBytes.Get()" is equivalent,right?

    opened by AlexLuya 1
Owner
Joubin Houshyar
Joubin Houshyar
Golang client for redislabs' ReJSON module with support for multilple redis clients (redigo, go-redis)

Go-ReJSON - a golang client for ReJSON (a JSON data type for Redis) Go-ReJSON is a Go client for ReJSON Redis Module. ReJSON is a Redis module that im

Nitish Malhotra 293 Dec 1, 2022
Redis client Mock Provide mock test for redis query

Redis client Mock Provide mock test for redis query, Compatible with github.com/go-redis/redis/v8 Install Confirm that you are using redis.Client the

null 150 Nov 22, 2022
Bxd redis benchmark - Redis benchmark tool for golang

使用 redis benchmark 工具, 测试 10 20 50 100 200 1k 5k 字节 value 大小,redis get set 性能。 r

bingxindan 0 Jan 22, 2022
redis client implement by golang, inspired by jedis.

godis redis client implement by golang, refers to jedis. this library implements most of redis command, include normal redis command, cluster command,

piaohao 108 Nov 26, 2022
Go client for Redis

Redigo Redigo is a Go client for the Redis database. Features A Print-like API with support for all Redis commands. Pipelining, including pipelined tr

null 9.4k Dec 8, 2022
Type-safe Redis client for Golang

Redis client for Golang ❤️ Uptrace.dev - distributed traces, logs, and errors in one place Join Discord to ask questions. Documentation Reference Exam

null 16k Dec 1, 2022
Go Redis Client

xredis Built on top of github.com/garyburd/redigo with the idea to simplify creating a Redis client, provide type safe calls and encapsulate the low l

Raed Shomali 19 Sep 26, 2022
godis - an old Redis client for Go

godis Implements a few database clients for Redis. There is a stable client and an experimental client, redis and exp, respectively. To use any of the

Simon Zimmermann 86 Apr 16, 2022
Redis client library for Go

go-redis go-redis is a Redis client library for the Go programming language. It's built on the skeleton of gomemcache. It is safe to use by multiple g

Alexandre Fiori 45 Nov 8, 2022
Type-safe Redis client for Golang

Redis client for Golang ❤️ Uptrace.dev - distributed traces, logs, and errors in one place Join Discord to ask questions. Documentation Reference Exam

null 16k Dec 3, 2022
Redisx: a library of Go utilities built on the redigo redis client library

redisx redisx is a library of Go utilities built on the redigo redis client libr

null 1 Dec 24, 2021
Redis client for Golang

Redis client for Golang To ask questions, join Discord or use Discussions. Newsl

null 0 Dec 23, 2021
Redis client for Golang

Redis client for Golang Discussions. Newsletter to get latest updates. Documentation Reference Examples RealWorld example app Other projects you may l

null 0 Dec 30, 2021
Simple key-value store abstraction and implementations for Go (Redis, Consul, etcd, bbolt, BadgerDB, LevelDB, Memcached, DynamoDB, S3, PostgreSQL, MongoDB, CockroachDB and many more)

gokv Simple key-value store abstraction and implementations for Go Contents Features Simple interface Implementations Value types Marshal formats Road

Philipp Gillé 493 Nov 28, 2022
Examples and code to assign a name to your MongoDB, MySQL, PostgreSQL, RabbitMQ, and redis connection.

your connection deserves a name ?? When your app interacts with an external system, assign a name to the connection. An external system in this contex

Andy Grunwald 28 Dec 6, 2022
A Golang implemented Redis Server and Cluster.

Godis is a golang implementation of Redis Server, which intents to provide an example of writing a high concurrent middleware using golang.

finley 2.4k Dec 7, 2022
Redis powered simple OTS service - contains two endpoints, to create and find a secret

Onetimesecret This is a simple service that stores and finds your secret. Small but powerfull service - does not have any unnesseccery dependencies. H

Dimitar Iliev 0 Aug 20, 2022
Redis-benchmark - Simple get, mget and pipelined get benchmark.

redis-benchmark Simple get, mget and pipelined get benchmark. Usage git clone https://github.com/Ali-A-A/redis-benchmark.git cd ./redis-benchmark dock

Ali Abbasi Alaei 0 Dec 31, 2021
Priority queue with message-group based partitioning and equal attention guarantee for each message group based on Redis

redis-ordered-queue-go Priority queue with message-group based partitioning and equal attention guarantee for each message group based on Redis What i

Ilya Melamed 8 Oct 21, 2022