A lightweight, Redis-like in-memory data structure store implemented in Go. This project aims to provide basic Redis functionality with a focus on simplicity and educational purposes.
- In-memory key-value storage
 - Support for basic Redis commands (SET, GET, PING, ECHO)
 - Key expiration with millisecond precision
 - Leader-Follower replication
 - RESP (Redis Serialization Protocol) implementation
 - RDB Persistence: Save and load the database to and from an RDB file for data persistence
 
- Go 1.15 or higher
 
- Clone the repository:
git clone https://github.com/yourusername/go-redis-clone.git - Navigate to the project directory:
cd go-redis-clone - Build the project:
go build -o go-redis-clone cmd/server/main.go 
To start the server:
./go-redis-clone
By default, the server runs on port 6379. You can specify a different port using the -port flag:
./go-redis-clone -port 6380
To run as a follower of another Redis server:
./go-redis-clone -replicaof <leader-host> <leader-port>
To enable RDB persistence, specify the directory and filename for the RDB file:
./go-redis-clone -dir <directory> -dbfilename <filename>The server will automatically load the database from the specified RDB file on startup and save the current state to the RDB file on shutdown.
PING: Test the connectionECHO: Echo the given stringSET: Set a key-value pair (with optional expiration)GET: Get the value of a keyINFO: Get information about the serverREPLCONF: Used in replicationPSYNC: Used in replicationWAIT: Wait for replicationKEYS: Retrieve all keys that match a given pattern (currently only supports the*pattern)CONFIG: Retrieve server configuration settings (currently supportsCONFIG GET dirandCONFIG GET dbfilename)- RDB Persistence:
- The server supports loading data from an RDB file and saving the current state to an RDB file.
 
 
The project is structured into several packages:
main: Entry point of the applicationhandler: Handles incoming commandsstorage: Implements the in-memory storereplication: Manages leader-follower replicationdomain: Defines interfaces and common typesresp: Implements the RESP protocolrdb: Manages RDB file persistence
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the Redis project
 - Created for educational purposes and to explore Go programming concepts
 
This is an educational project and is not intended for production use. For a robust, feature-complete Redis implementation, please use the official Redis project.