MyRedis
A Redis clone implementation built from scratch in Go

MyRedis is a Redis clone implementation built from scratch to understand the internals of in-memory data stores and network protocols.
Key Features
- Redis Protocol Implementation: Full RESP (Redis Serialization Protocol) parser for command handling
- In-Memory Key-Value Store: High-performance storage for strings and hashes
- Concurrent Connections: Handle multiple client connections simultaneously using goroutines
- Data Persistence: Append-Only File (AOF) for crash recovery and data durability
- Multiple Commands: Support for SET, GET, DEL, HSET, HGETALL, and more
- Easily Extendable: Simple design for adding new commands and features
- Redis CLI Compatible: Works with standard
redis-clitool
Supported Commands
- String Operations:
SET,GET,DEL - Hash Operations:
HSET,HGETALL,HDEL - Basic Commands:
PING,ECHO
How It Works
- Server Initialization: Starts on port 6379 by default
- Connection Handling: Accepts multiple client connections using goroutines
- Protocol Parsing: RESP parser decodes incoming commands
- Command Execution: Handler processes commands and updates in-memory store
- Data Persistence: AOF logs all write operations for recovery
- Response Generation: Sends RESP-formatted responses back to clients
Technologies Used
- Language: Go (for performance and concurrency)
- Protocol: RESP (Redis Serialization Protocol)
- Concurrency: Goroutines for handling multiple clients
- Persistence: Append-Only File (AOF)
- Networking: Go net package
- Tools: redis-cli for testing
Project Structure
-
main.go- Server initialization and lifecycle -
resp.go- RESP protocol parser -
handler.go- Command processing logic -
aof.go- Data persistence layer