A Golang implemented Redis server
Godisis a simple implementation of Redis Server, which intents to provide an example of writing a high concurrent middleware using golang.
Please be advised, NEVER think about using this in production environment.
This repository implemented most features of redis, including 5 data structures, ttl, publish/subscribe, AOF persistence and server side cluster mode.
If you could read Chinese, you can find more details in My Blog.
You can get runnable program in the releases of this repository, which supports Linux and Darwin system.
You could use redis-cli or other redis client to connect godis server, which listens on 127.0.0.1:6379 on default mode.
The program will try to read config file path from environment variable
If environment variable is not set, then the program try to read
redis.confin the working directory.
If there is no such file, then the program will run with default config.
Godis can work in cluster mode, please append following lines to redis.conf file
peers localhost:7379,localhost:7389 // other node in cluster self localhost:6399 // self address
We provide node1.conf and node2.conf for demonstration. use following command line to start a two-node-cluster:
CONFIG=node1.conf ./godis-darwin & CONFIG=node2.conf ./godis-darwin &
The cluster is transparent to client. You can connect to any node in the cluster to access all data in the cluster:
redis-cli -p 6399
If you want to read my code in this repository, here is a simple guidance.
I suggest focusing on the following directories:
This project is licensed under the GPL license.