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 them simply add.

import "insmo.com/godis/redis"

or

import "insmo.com/godis/exp"

Both versions provide a redis package which is used to create a client and talk to the database. For a quick start check out either projects readme and example. Package reference is also available.

  1. godis/redis
  2. godis/exp

Status

Project is old and unmaintained.

Owner
Simon Zimmermann
Software engineer with a background in the games industry, working on the transition to sustainable freight.
Simon Zimmermann
Comments
  • compilation error with weekly

    compilation error with weekly

    I am trying to port my little url shortener kurz.go (https://github.com/fs111/kurz.go), which uses godis to the latest weekly of golang and therefore I have to re-install all packages, that I use.

    When I try to install godis, I get the following error:

    $ go get github.com/simonz05/godis

    github.com/simonz05/godis

    ../go/src/pkg/github.com/simonz05/godis/godis.go:78: too few values in struct initializer

    What am I missing?

  • How to close a Client...

    How to close a Client...

    I'm probably overlooking something, but I don't see any way to close a client and release the connections it's holding.

    This would be particularly important for pipeline clients where several might be opened simultaneously.

  • import

    import "github.com/simonz05/godis/redis": cannot find package

    I'm trying to install godis on Go 1 Windows amd64, but I dunno why (maybe the tags) I'm not getting the correct repo from github.

    package github.com/simonz05/godis/redis
            imports github.com/simonz05/godis/redis
            imports github.com/simonz05/godis/redis: import "github.com/simonz05/godis/redis": cannot find package
    

    I see that the repo being pulled in my GOPATH does not have the same structure than the current master on github (maybe because the Go1 version pulls the Go1 tag).

    Maybe fix tag?

  • panic: runtime error: invalid memory address

    panic: runtime error: invalid memory address

    Hi,

    I'm trying to package godis for Arch Linux. I'm on a 64-bit computer, with go version "go1.0.2". After moving the examples directory away and compiling, the tests give me this:

    === RUN TestServer --- FAIL: TestServer (0.00 seconds) godis_test.go:15: monitor expected <nil> got <nil>, err(Connection error 127.0.0.1:6379) godis_test.go:15: requirepass foobared expected <nil> got <nil>, err(Connection error 127.0.0.1:6379) godis_test.go:15: ping authenticated expected <nil> got <nil>, err(Connection error 127.0.0.1:6379) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x30 pc=0x42e14a]

    goroutine 13 [running]: testing._func_003(0x7f88ab033fa8, 0x7f88ab033100, 0x7f88ab033fb8, 0x7f88ab033d18) /usr/lib/go/src/pkg/testing/testing.go:268 +0xf3 ----- stack segment boundary ----- github.com/simonz05/godis.(_Reply).StringArray(0x0, 0x0, 0x7f88ab033e70, 0x200000002) /tmp/yaourt-tmp-alexander/aur-go-godis/src/src/github.com/simonz05/godis/conn.go:134 +0x20 github.com/simonz05/godis.(_Reply).StringMap(0x0, 0x566b34, 0x757165720000000b, 0x0) /tmp/yaourt-tmp-alexander/aur-go-godis/src/src/github.com/simonz05/godis/conn.go:155 +0x25 github.com/simonz05/godis.TestServer(0xf840000540, 0xbc05ca0) /tmp/yaourt-tmp-alexander/aur-go-godis/src/src/github.com/simonz05/godis/commands_test.go:647 +0x2a6 testing.tRunner(0xf840000540, 0x636be0, 0x0, 0x0) /usr/lib/go/src/pkg/testing/testing.go:273 +0x6f created by testing.RunTests /usr/lib/go/src/pkg/testing/testing.go:349 +0x782

    goroutine 1 [chan receive]: testing.RunTests(0x400c00, 0x636b08, 0x1600000016, 0x0, 0x627698, ...) /usr/lib/go/src/pkg/testing/testing.go:350 +0x7a5 testing.Main(0x400c00, 0x636b08, 0x1600000016, 0x6355f8, 0x300000003, ...) /usr/lib/go/src/pkg/testing/testing.go:285 +0x7a main.main() /tmp/go-build230035416/github.com/simonz05/godis/_test/_testmain.go:91 +0x91

    goroutine 2 [syscall]: created by runtime.main /home/alexander/archpackages/community/go/trunk/src/go/src/pkg/runtime/proc.c:221

    goroutine 4 [syscall]: syscall.Syscall6() /home/alexander/archpackages/community/go/trunk/src/go/src/pkg/syscall/asm_linux_amd64.s:40 +0x5 syscall.EpollWait(0xf800000006, 0xf84006d170, 0xa0000000a, 0xffffffff, 0xc, ...) /usr/lib/go/src/pkg/syscall/zerrors_linux_amd64.go:1781 +0xa1 net.(_pollster).WaitFD(0xf84006d160, 0xf84004c2c0, 0x0, 0x0, 0x0, ...) /usr/lib/go/src/pkg/net/fd_linux.go:146 +0x110 net.(_pollServer).Run(0xf84004c2c0, 0x0) /usr/lib/go/src/pkg/net/fd.go:236 +0xe4 created by net.newPollServer /usr/lib/go/src/pkg/net/newpollserver.go:35 +0x382 exit status 2 FAIL github.com/simonz05/godis 0.008s

    Here's the package, if you're on 64-bit Arch Linux and want an easy way to reproduce the issue: https://aur.archlinux.org/packages.php?ID=61009

  • Get()-style methods don't emit Redis commands in a Multi() context

    Get()-style methods don't emit Redis commands in a Multi() context

    Get() unconditionally returns an error when called within a Multi() context. Modifying the code for Get() to check for the existence of a transaction still doesn't result in a GET command being emitted to Redis.

    I suspect most of the data retrieval methods (those that don't return *Result) have similar issues, where they don't emit Redis commands.

  • Auth must be called before Select

    Auth must be called before Select

    When I try to connect to database != 0 with authentication. I must call Auth command before Select command.

    Simple code that should work after my change:

    ---- begin of test.go ---- package main

    import ( "godis" )

    func main() { db := godis.New("", 1, "secret")

    foo, err := db.Get("foo")
    if err == nil {
        println(foo.String())
    } else {
        println(err.String())
    }
    

    } ---- end of test.go ----

  • calling New with a bad netaddr

    calling New with a bad netaddr

    Hello,

    First off, thanks for contributing the library. It appears to work pretty well.

    If you call New with bad netaddr (i.e. 127.0.0.1 instead of 127.0.0.1:6379) then you will get a panic.

    Here is the snippet:

    na := strings.SplitN(netaddr, ":", 2) return &Client{Addr: na[1], Db: db, Password: password, net: na[0], pool: newPool()}

    If there is not a colon in the addr passed then an index error occurs.

    I'm not sure what the best mechanism is to address. You could check the length like this:

    if len(na) != 2 { return nil }

    Or you could check before calling split and do the same with strings.IndexRune(netaddr, ":").

    Or you could make sure that it a valid net addr by doing a net.ResolveTCPAddr("tcp4", netaddr) and catch it on the error.

    Was going to fork this and send a pull request just didn't wanted to do so without getting a stylistic blessing.

    Thanks again!

    Shelby

  • INFO is truncated occasionally

    INFO is truncated occasionally

    I'm polling a local Redis 2.6 server with:

    client := redis.NewClient("localhost", 0, "")
    reply, err := client.Call("INFO")
    if err != nil {
        return ""
    }
    client.Call("QUIT")
    return reply.Elem.String()
    

    (And the equivalent with the non-exp package)

    Occasionally, reply.Elem.String() will return truncated output:

    "# Server\r\nredis_version:2.5.10\r\nredis_git_sha1:ac2febdb\r\nredis_git_dirty:0\r\nos:Linux 3.2.0-24-virtual x86_64\r\narch_bits:64\r\nmultiplexing_api:epoll\r\ngcc_version:4.6.3\r\nprocess_id:776\r\nrun_id:bdf2888b2974bccff9db6eb473abeb2ff2589d54\r\ntcp_port:10030\r\nuptime_in_seconds:14110158\r\nuptime_in_days:163\r\nlru_clock:1572223\r\n\r\n# Clients\r\nconnected_clients:5\r\nclient_longest_output_list:0\r\nclient_biggest_input_buf:0\r\nblocked_clients:0\r\n\r\n# Memory\r\nused_memory:941320\r\nused_memory_human:919.26K\r\nused_memory_rss:6828032\r\nused_memory_peak:104915264\r\nused_memory_peak_human:100.05M\r\nused_memory_lua:30720\r\nmem_fragmentation_ratio:7.25\r\nmem_allocator:jemalloc-3.0.0\r\n\r\n# Persistence\r\nloading:0\r\nrdb_changes_since_last_save:75038\r\nrdb_bgsave_in_progress:0\r\nrdb_last_save_time:1357899518\r\nrdb_last_bgsave_status:ok\r\nrdb_last_bgsave_time_sec:0\r\nrdb_current_bgsave_time_sec:-1\r\naof_enabled:0\r\naof_rewrite_in_progress:0\r\naof_rewrite_scheduled:0\r\naof_last_rewrite_time_sec:-1\r\naof_current_rewrite_time_sec:-1\r\n\r\n# Stats\r\ntotal_connections_received:440713\r\ntotal_commands_processed:15689002680\r\ninstantaneous_ops_per_sec:13878\r\nrejected_connections:0\r\nexpired_keys:0\r\nevicted_keys:0\r\nkeyspace_hits:2\r\nkeyspace_misses:95626\r\npubsub_channels:0\r\npubsub_patterns:0\r\nlatest_fork_usec:2982\r\n\r\n# Replication\r\nrole:master\r\nconnected_slaves:0\r\n\r\n# CPU\r\nused_cpu_sys:53159.38\r\nused_cpu_user:92844.89\r\nused_cpu_sys_children:828.06\r\nused_cpu_user_children:1923.70\r\n\r\n# Keyspace\r\n"
    

    This happens using both exp and regular redis.

  • doc update

    doc update

    the install chapter

    Importing godis to your code can be done with import "github.com/simonz05/godis". Thats it!

    import "github.com/simonz05/godis" to import "github.com/simonz05/godis/redis"

  • MULTI..EXEC transactions and asynchronous Call commands

    MULTI..EXEC transactions and asynchronous Call commands

    Hi,

    This pull request addresses three issues:

    1. When a MULTI..EXEC transaction fails because of a WATCH condition, an error is returned by ReadAll. It is difficult to test this error to see if it was due to an aborted transaction or something else. I have named the error as ErrMultiAborted, so now you can just do a check like so:

      if err == redis.ErrMultiAborted { // transaction aborted, try again

    2. The Call method of an AsyncClient cannot return any errors, so I removed the err return value. It calls Write in bytes.Buffer, but the docs for that method explicitly say it will never return an err (it just has the return type to match the io.Writer interface). Removing this lets careful people know it is okay to assume the call will succeed.

    3. When using WATCH with MULTI..EXEC transactions, the normal pattern is:

      WATCH foo GET foo MULTI do stuff using the value of foo that is now guaranteed to not change EXEC

    AsyncClient handles the MULTI..EXEC part great, but it is a bit verbose to run the commands that happen before the MULTI is issued. This adds a SyncCall to AsyncClient that works more like Call from Client. It fails if there are already commands in the queue.

    Thanks,

    Russ

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

Dec 27, 2022
GoBigdis is a persistent database that implements the Redis server protocol. Any Redis client can interface with it and start to use it right away.

GoBigdis GoBigdis is a persistent database that implements the Redis server protocol. Any Redis client can interface with it and start to use it right

Apr 27, 2022
Bxd redis benchmark - Redis benchmark tool for golang

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

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,

Dec 6, 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

Jan 1, 2023
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

Jan 1, 2023
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

Sep 26, 2022
Google Go Client and Connectors for Redis

Go-Redis Go Clients and Connectors for Redis. The initial release provides the interface and implementation supporting the (~) full set of current Red

Oct 25, 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

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

Jan 4, 2023
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

Dec 24, 2021
Redis client for Golang
Redis client for Golang

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

Dec 23, 2021
Redis client for Golang
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

Dec 30, 2021
High-performance framework for building redis-protocol compatible TCP servers/services

Redeo The high-performance Swiss Army Knife for building redis-protocol compatible servers/services. Parts This repository is organised into multiple

Jan 4, 2023
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

Dec 24, 2022
Redis Sorted Sets Benchmark

redis-zbench-go Redis Sorted Sets Benchmark Overview This repo contains code to trigger load ( ZADD ) or query (ZRANGEBYLEX key min max) benchmarks, w

May 18, 2021
Use Redis' MONITOR to draw things in a terminal
Use Redis' MONITOR to draw things in a terminal

Redis Top Redistop uses MONITOR to watch Redis commands and shows per command and per host statistics. Because MONITOR streams back all commands, its

Aug 30, 2022
Examples and code to assign a name to your MongoDB, MySQL, PostgreSQL, RabbitMQ, and redis connection.
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

Dec 14, 2022
redis protocol server for go.

redigosrv what redis server侧的golang版本实现。 why 作为后端RD,你开发的,维护的最多的应该就是你的server,作为服务的提供方来说,想要和客户端进行有效的交互,首先要要能理解信息的含义,因此一套通信协议是必须的。 为什么选择redis协议,应用层有很多成熟的

Nov 30, 2021