Skip to content

A lightweight, Redis-inspired in memory key-value store built in modern C/C++. Implements core Redis commands for Strings, Lists, and Hashes, and uses epoll for efficient I/O multiplexing to handle multiple clients concurrently , just like the real Redis server.

License

Notifications You must be signed in to change notification settings

YashSuthar983/uffCS_TALKS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uffCS_TALKS

A lightweight, high-performance Redis-inspired in-memory key-value store written in modern C/C++.

This project implements many core features of Redis—including support for Strings, Lists, and Hashes—with custom low-level data structures and efficient networking using epoll for I/O multiplexing. It is designed for educational purposes and to explore systems-level programming concepts.


✨ Features

  • 🧠 Custom HashMap: Built from scratch with Murmur3 hash function for fast key lookup.
  • 📦 List Structures: Includes ListPack and QuickList to simulate Redis-like list operations.
  • Efficient I/O: Uses epoll to support multiple concurrent client connections.
  • 🛠️ Modular Codebase: Clean separation between networking, data handling, and command processing.

✅ Supported Commands

String Commands

  • GET key
  • SET key value
  • INCR key
  • DECR key
  • EXISTS key
  • DEL key
  • TYPE key
  • ECHO message
  • PING
  • HELP [command]

List Commands

  • LPUSH key value [value ...]
  • RPUSH key value [value ...]
  • LPOP key
  • RPOP key
  • LLEN key
  • LRANGE key start end (use -1 for end to indicate tail)

Hash Commands

  • HSET hash field value [field value ...]
  • HGET hash field
  • HDEL hash field [field ...]
  • HGETALL hash

🏗️ Build Instructions

Prerequisites

  • GCC or Clang
  • CMake ≥ 3.13
  • Linux environment (for epoll)

Steps

git clone https://github.com/YashSuthar983/uffCS_TALKS.git
cd uffCS_TALKS
chmod +x run.sh
./run.sh
# Or manual build
cmake -B build -S .
cmake --build build
./build/server

🧪 Quick Start (Client + Server)

Start the server (defaults to port 2345):

./build/server

Run the interactive client:

python3 client/client.py

Example session (actual server protocol output):

> SET mykey Hello
+OK

> GET mykey
$5
Hello

> LPUSH list 1 2 3
+OK

> LLEN list
:3

> LRANGE list 0 -1
$1
3
$1
2
$1
1

> HSET myhash field1 value1
+OK

> HGET myhash field1
$7
value1

> HGETALL myhash
*2
$6
field1
$7
value1

> HELP
$...
HELP [command]
Commands:
PING [message]
ECHO message
EXISTS key
TYPE key
DEL key [key ...]
GET key
SET key value
INCR key
DECR key
LPUSH key value [value ...]
RPUSH key value [value ...]
LPOP key
RPOP key
LLEN key
LRANGE key start end (use -1 as end for tail)
HSET hash field value [field value ...]
HGET hash field
HDEL hash field [field ...]
HGETALL hash

📁 Directory Structure

uffCS_TALKS/
├── include/           # Public headers (APIs shared across modules)
├── src/
│   ├── core/          # Core KV store & command execution
│   ├── ds/            # Data structures (ListPack, QuickList)
│   └── server/        # Networking / epoll server
├── client/
│   └── client.py      # Simple interactive client
├── run.sh             # Build & run script
├── CMakeLists.txt     # Build configuration
└── .gitignore

📝 Protocol

  • Minimal RESP-like protocol: each token is encoded as a bulk string
    • $<len>\r\n<TOKEN>\r\n
  • The server currently returns bulk strings and integers, and in some cases arrays (e.g., HGETALL).
  • LRANGE returns a sequence of bulk strings (no array header yet).

🪵 Logging

  • Leveled logging with TRACE, DEBUG, INFO, WARN, ERROR.
  • Configure at runtime:
    • Environment: UFFCS_LOG_LEVEL=trace ./build/server
    • CLI flags: ./build/server --log-level=info --debug or --no-debug
  • Logs include file and line for easier debugging.

🚀 Roadmap

  • Persistence (RDB / AOF)
  • Pub/Sub support
  • Auth system
  • More hash and list operations
  • Cluster mode simulation

🤝 Contribution

PRs are welcome! If you find any issues or want to suggest improvements, feel free to open an issue or submit a pull request.


📜 License

This project is licensed under the MIT License.

About

A lightweight, Redis-inspired in memory key-value store built in modern C/C++. Implements core Redis commands for Strings, Lists, and Hashes, and uses epoll for efficient I/O multiplexing to handle multiple clients concurrently , just like the real Redis server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages