Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis-Like Server in Python

A learning project implementing a simplified Redis-like in-memory key-value store with the Redis Serialization Protocol (RESP).

🎓 Purpose

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

🌟 Features

  • Concurrent connections using threading
  • Redis protocol (RESP) for client-server communication
  • In-memory key-value storage
  • Supported commands:
    • GET key - Retrieve value for a key
    • SET key value - Store a key-value pair
    • DELETE key - Remove a key
    • FLUSH - Clear all keys
    • MGET key1 key2 ... - Get multiple keys
    • MSET key1 val1 key2 val2 ... - Set multiple key-value pairs

🏃 Quick Start

Start the server:

python3 server.py

Server will listen on 127.0.0.1:9000

Use the client:

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()

📁 Project Structure

.
├── server.py           # Main server implementation
├── protocol.py         # Redis protocol (RESP) handler
├── protocol_client.py  # Client library
└── README.md          # This file

🧪 Running Tests

python3 protocol_client.py

🔧 Technical Details

  • Protocol: Redis Serialization Protocol (RESP)
  • Concurrency: Multi-threaded (one thread per client)
  • Storage: In-memory dictionary
  • Language: Python 3.x

📚 Inspiration

This project is inspired by the excellent tutorial: Building a Simple Redis Server with Python by Charles Leifer

🎯 Roadmap

  • 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

📝 License

MIT License - feel free to use for learning!

🤝 Contributing

This is a personal learning project, but feedback and suggestions are welcome!

About

'build-your-own-x' inspired project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages