Godis is simple implementation of Redis-like in-memory cache written in Go.
-
A key-value storage that supports strings, lists and hashes as stored values.
-
Automatic expiration of a key. TTL can be optionally assigned to a key.
-
The following commands are supported:
common string list hash command get llen hkeys type set lindex hexists keys lpop hget exists lpush hgetall del rpop hset expire rpush hdel expireat lset pexpire pexpireat ttl pttl persist The commands have the same signature and work exactly the same as corresponding commands in Redis below version 2.4 (Godis does not support multikey and multivalue commands).
-
Both REdis Serialization Protocol (RESP) and Inline Commands Protocol are supported. Thus simple
telnetandredis-cliclients can be used to play with Godis. Moreover, performance can be tested withredis-benchmark. -
Golang API client
-
Write-ahead logging based persistence. Log compaction is not yet implemented and format of the log is not optimized due to reasons of simplicity.
To build Godis as a Docker image install and run Docker and use the following command:
docker build -t godis github.com/ekundo/godis
As a first step start Godis server with:
docker run -v $(pwd):/work -p 2121:2121 -it --rm godis
Then send commands to server using any tcp client like telnet
$ telnet 127.0.0.1 2121
set foo bar
+OK
get foo
$3
bar
Although redis-cli is the best choice:
$ redis-cli -p 2121 -h 127.0.0.1
redis> set foo bar
OK
redis> get foo
"bar"
Use command to get the list of available commands.
Details of each command from the list can be found at redis command guide.
Below are the testing results performed on my MacBook Pro 13 (Intel Core i5 2.9 GHz, 8 GB LPDDR3, SSD)
$ redis-benchmark -p 2121 -r 65536 -q -t SET,GET,LPUSH,RPUSH,LPOP,RPOP,HSET
SET: 21640.34 requests per second
GET: 26116.48 requests per second
LPUSH: 23342.67 requests per second
RPUSH: 22925.26 requests per second
LPOP: 24313.15 requests per second
RPOP: 25227.04 requests per second
HSET: 19105.85 requests per second
Test result are compared with such of original Redis server:
redis-benchmark -r 65536 -q -t SET,GET,LPUSH,RPUSH,LPOP,RPOP,HSET
SET: 50994.39 requests per second
GET: 51072.52 requests per second
LPUSH: 52938.06 requests per second
RPUSH: 52328.62 requests per second
LPOP: 52548.61 requests per second
RPOP: 51867.22 requests per second
HSET: 51519.84 requests per second