Your own miniature redis written in Go.
MyRedis is a minimal yet functional in-memory key-value store inspired by Redis. Designed for learning and experimentation, MyRedis demonstrates the core concepts of Redis, including its protocol, data structures, and command parsing, all implemented from scratch.
- A Redis clone that lets you store and retrieve strings and hashes and delete them.
- Parse RESP (Redis Serialization Protocol) to handle commands and send responses.
- Handle multiple client connections simultaneously using goroutines.
- Persist data to disk using an Append Only File (AOF) so the server can recover after crashes or restarts.
- Accept and manage client connections with simple networking.
- Easily extendable design for adding new commands or features.
- Go (Latest)
- redis-cli (
sudo apt install redis-tools
)
Clone this repository:
git clone https://github.com/DSCmatter/MyRedis.git
cd MyRedis
cd src/
You can run the server manually or use the provided shell script.
sudo snap stop redis
go run *.go // runs all files in the directory
redis-cli ping // will output with PONG
By default, the server runs on 6379
.
A shell script runMyRedis.sh
is included to simplify running and testing:
chmod +x runMyRedis.sh
./runMyRedis.sh
OR
bash runMyRedis.sh
This script stops any existing Redis instance, runs MyRedis, waits briefly, then connects with redis-cli
.
You can interact with MyRedis using the redis-cli
tool or any compatible Redis client:
redis-cli
Try basic commands:
set name leon
get name
del name
hset names v1 ada
hset names v2 leon
hgetall names
Response:
1) "v1"
2) "Ada"
3) "v2"
4) "leon
main.go # Initializer
resp.go # RESP parser
handler.go # handles basic commands
aof.go # data persistence
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks for checking out MyRedis! ⭐ Star the repo if you find it useful or inspiring.