Skip to content

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

Notifications You must be signed in to change notification settings

Blue-Davinci/GoRed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoRed: An In-Memory Redis-like Server in Go

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.

Features

  • 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.

Requirements

  • Go 1.20+ for building and running the server.

Getting Started

Installation

  1. Clone the repository:
    git clone https://github.com/Blue-Davinci/GoRed.git
    cd goredis
  2. 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.

Usage

  1. Start the server:
    make run
  2. Connect using redis-cli:
redis-cli -p 5001
  1. 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"

Project Structure

- **`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.

Development

Prerequisites

Install the dependencies using:

go mod tidy

Running Tests

Run the tests using:

go test ./...

Configuration

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! 🚀

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published