GoRedis is a lightweight, in-memory key-value store implemented in Go, inspired by Redis. This project demonstrates building a simple yet functional key-value store with basic command support, such as SET
, GET
, and HELLO
.
- In-Memory Key-Value Storage: Store and retrieve data efficiently without persistence.
- RESP Protocol Support: Implements a subset of the Redis Serialization Protocol (RESP).
- Concurrent Connections: Handle multiple clients concurrently with Go's goroutines and channels.
- Configurable Server: Easily configure the listening address for the server.
- Integration Testing: Includes tests using the official Redis Go client.
- Go 1.20+ for building and running the server.
- Clone the repository:
git clone https://github.com/Blue-Davinci/GoRed.git cd goredis
- Use the provided
makefile
to build and run the server:
- Build the server:
make build
This will compile the server and place the binary in the bin/ directory.
- Run the server:
make run
By default, the server will listen on :5001. You can customize this address in the Makefile or pass it as an argument.
- Start the server:
make run
- Connect using redis-cli:
redis-cli -p 5001
- Interact with the server:
127.0.0.1:5001> SET name GoRedis
OK
127.0.0.1:5001> GET name
"GoRedis"
127.0.0.1:5001> HELLO
1) "server"
2) "redis"
- **`main.go`**: Entry point of the server.
- **`keyval.go`**: Implementation of the in-memory key-value store.
- **`peer.go`**: Manages client connections.
- **`proto.go`**: Protocol logic for RESP commands.
- **`proto_test.go`**: Placeholder for testing protocol functionality.
- **`server_test.go`**: Integration tests using the official Redis client.
Install the dependencies using:
go mod tidy
Run the tests using:
go test ./...
The server can be configured using command-line flags:
- `--listenAddr`: Specifies the address on which the server listens for connections. Default is `:5001`.
Contributions are welcome! If you have ideas for improvements or encounter issues, feel free to open an issue or a pull request. License
This project is licensed under the MIT License.
Enjoy using GoRedis! 🚀