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.
- 🧠 Custom HashMap: Built from scratch with Murmur3 hash function for fast key lookup.
- 📦 List Structures: Includes
ListPackandQuickListto simulate Redis-like list operations. - ⚡ Efficient I/O: Uses
epollto support multiple concurrent client connections. - 🛠️ Modular Codebase: Clean separation between networking, data handling, and command processing.
GET keySET key valueINCR keyDECR keyEXISTS keyDEL keyTYPE keyECHO messagePINGHELP [command]
LPUSH key value [value ...]RPUSH key value [value ...]LPOP keyRPOP keyLLEN keyLRANGE key start end(use-1forendto indicate tail)
HSET hash field value [field value ...]HGET hash fieldHDEL hash field [field ...]HGETALL hash
- GCC or Clang
- CMake ≥ 3.13
- Linux environment (for
epoll)
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/serverStart the server (defaults to port 2345):
./build/serverRun the interactive client:
python3 client/client.pyExample 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 hashuffCS_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- 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). LRANGEreturns a sequence of bulk strings (no array header yet).
- 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 --debugor--no-debug
- Environment:
- Logs include file and line for easier debugging.
- Persistence (RDB / AOF)
- Pub/Sub support
- Auth system
- More hash and list operations
- Cluster mode simulation
PRs are welcome! If you find any issues or want to suggest improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.