Skip to content

adityar235/KeyClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Redis Client in C++ (RESP2 Protocol)

A lightweight Redis client written in C++ that communicates with the official Redis server using the RESP2 (Redis Serialization Protocol).
This project demonstrates low-level socket programming, command parsing, and protocol implementation.


📌 Features

✅ Connects to official Redis server using TCP sockets
✅ Implements RESP2 protocol for communication
✅ Command parsing using Regex
✅ Handles server responses dynamically
✅ Automated build using Makefile
✅ Interactive CLI for sending Redis commands


🏗️ Project Architecture

The client follows a structured workflow:

User Input ↓ Command Handler ↓ Build RESP Command ↓ Send Command via Socket ↓ Response Handler ↓ Display Output


⚙️ How It Works

1️⃣ Socket Connection

  • Creates a TCP socket.
  • Connects to the Redis server using IP and port.
  • Establishes communication channel.

2️⃣ Command Handler

  • Takes input commands from user.
  • Uses Regex library to validate and parse commands.
  • Converts command into structured tokens.

3️⃣ RESP Command Builder

  • Converts user command into RESP2 format.
  • Example conversion:

User Input

SET key value

RESP Format

*3 $3 SET $3 key $5 value


4️⃣ Command Sender

  • Sends formatted RESP command to Redis server through socket.

5️⃣ Response Handler

  • Reads Redis server response.
  • Parses different RESP response types:
    • Simple Strings
    • Errors
    • Integers
    • Bulk Strings
    • Arrays

6️⃣ Output Display

  • Converts server response into readable output for user.

🛠️ Tech Stack

  • C++
  • Socket Programming (POSIX)
  • Regex Library
  • RESP2 Protocol
  • Makefile

About

This is a redis client in c++ build from scratch using RESP2 protocol which can be used to talk with official redis server.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors