A learning project implementing a simplified Redis-like in-memory key-value store with the Redis Serialization Protocol (RESP).
This project is built for learning and understanding:
- Socket programming in Python
- Network protocols and serialization
- Multi-threaded server architecture
- Redis protocol (RESP) implementation
Status: 🚧 Work in progress - actively adding features and improvements
- Concurrent connections using threading
- Redis protocol (RESP) for client-server communication
- In-memory key-value storage
- Supported commands:
GET key- Retrieve value for a keySET key value- Store a key-value pairDELETE key- Remove a keyFLUSH- Clear all keysMGET key1 key2 ...- Get multiple keysMSET key1 val1 key2 val2 ...- Set multiple key-value pairs
python3 server.pyServer will listen on 127.0.0.1:9000
from protocol_client import RedisClient
client = RedisClient()
# Set a value
client.set('mykey', 'myvalue')
# Get a value
result = client.get('mykey')
print(result) # b'myvalue'
# Delete a key
client.delete('mykey')
# Close connection
client.close().
├── server.py # Main server implementation
├── protocol.py # Redis protocol (RESP) handler
├── protocol_client.py # Client library
└── README.md # This file
python3 protocol_client.py- Protocol: Redis Serialization Protocol (RESP)
- Concurrency: Multi-threaded (one thread per client)
- Storage: In-memory dictionary
- Language: Python 3.x
This project is inspired by the excellent tutorial: Building a Simple Redis Server with Python by Charles Leifer
- Basic server with socket handling
- Threading for concurrent connections
- Redis protocol implementation
- Core commands (GET, SET)
- Extended commands (DELETE, FLUSH, MGET, MSET)
- Error handling
- Persistence (save to disk)
- More data types (lists, sets, hashes)
- Pub/Sub support
- TTL (time-to-live) for keys
- Benchmarking and performance testing
MIT License - feel free to use for learning!
This is a personal learning project, but feedback and suggestions are welcome!