A simple, lightweight Redis clone written in Go, featuring an in-memory data store with append-only file (AOF) persistence and a custom command-line interface (CLI).
- Introduction
- Features
- Architecture
- Getting Started
- Usage
- Supported Commands
- Project Structure
- Roadmap
- Contributing
- License
- Acknowledgments
Godis is a Redis-inspired in-memory data store built from scratch in Go. It supports basic Redis commands and features an append-only file (AOF) persistence mechanism to ensure data durability across restarts. Additionally, Godis includes a custom CLI for interacting with the server without relying on external tools.
- In-memory key-value data store
- Append-only file (AOF) persistence
- RESP (REdis Serialization Protocol) implementation
- Custom Godis CLI for server interaction
- Supports basic Redis commands:
SET
,GET
,PING
,ECHO
- Thread-safe operations using Goroutines and Mutexes
- Modular codebase with clear package separation
Godis is structured into several packages to promote modularity and maintainability:
- cmd: Contains the entry points for the server and CLI.
- internal/aof: Manages the append-only file persistence.
- internal/commands: Handles client connections and command execution.
- internal/datastore: Implements the in-memory data store.
- internal/protocol: Parses and constructs RESP messages.
- internal/server: Contains the TCP server logic.
- Go 1.23 or higher installed on your machine
- Git for cloning the repository (optional)
-
Clone the repository
git clone https://github.com/manimovassagh/Godis.git
-
Navigate to the project directory
cd Godis
-
Build the server
go build -o godis-server ./cmd/server
-
Build the CLI
go build -o godis-cli ./cmd/client
Run the Godis server by executing:
./godis-server
The server will start listening on port 6379
.
In a new terminal window, start the Godis CLI:
./godis-cli
You should see:
Godis CLI connected to localhost:6379
Type 'exit' or 'quit' to close the CLI.
godis>
You can now enter commands to interact with the server.
-
PING
godis> PING PONG
-
ECHO
godis> ECHO "Hello, Godis!" Hello, Godis!
-
SET
godis> SET mykey "Some value" OK
-
GET
godis> GET mykey Some value
-
EXIT / QUIT
godis> EXIT Bye!
Godis/
βββ cmd/
β βββ server/
β β βββ main.go // Server entry point
β βββ client/
β βββ main.go // CLI entry point
βββ internal/
β βββ aof/
β β βββ aof.go // AOF persistence
β βββ commands/
β β βββ commands.go // Command handling
β βββ datastore/
β β βββ datastore.go // In-memory data store
β βββ protocol/
β β βββ protocol.go // RESP implementation
β βββ server/
β βββ server.go // TCP server logic
βββ go.mod // Go module file
βββ README.md // Project documentation
- Additional Commands: Implement more Redis commands such as
DEL
,INCR
,EXISTS
. - Data Structures: Add support for lists, sets, hashes, and sorted sets.
- Expiration: Implement key expiration and TTL functionality.
- Persistence Enhancements: Introduce snapshotting (RDB files) and AOF rewriting.
- Configuration: Allow server settings via configuration files or command-line flags.
- Improved CLI: Enhance the CLI with command history, auto-completion, and syntax highlighting.
- Testing: Develop comprehensive unit and integration tests for all components.
- Logging: Implement structured logging for better observability.
Contributions are welcome! Please follow these steps:
-
Fork the repository
-
Create a new feature branch
git checkout -b feature/my-feature
-
Commit your changes
git commit -am 'Add new feature'
-
Push to the branch
git push origin feature/my-feature
-
Open a pull request
Please ensure your code adheres to the project's coding standards and includes appropriate tests.
This project is licensed under the MIT License - see the LICENSE file for details.
- Redis for the inspiration behind this project.
- The Go community for providing excellent tools and documentation.
- Everyone who contributes to open-source projects and promotes knowledge sharing.
Note: This project is for educational purposes to understand how key-value stores and network servers work. It is not intended for production use.