๐Ÿ“ฆ ronitrajfr / ronis

implementation of redis-like server

โ˜… 2 stars โ‘‚ 0 forks ๐Ÿ‘ 2 watching โš–๏ธ MIT License
bunnoderedissockettcptypescript
๐Ÿ“ฅ Clone https://github.com/ronitrajfr/ronis.git
HTTPS git clone https://github.com/ronitrajfr/ronis.git
SSH git clone git@github.com:ronitrajfr/ronis.git
CLI gh repo clone ronitrajfr/ronis
ronitrajfr ronitrajfr some changes f83c0c7 7 months ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ app
๐Ÿ“„ .gitattributes
๐Ÿ“„ .gitignore
๐Ÿ“„ bun.lockb
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ tsconfig.json
๐Ÿ“„ your_program.sh
๐Ÿ“„ README.md

Ronis

This is a simple Redis-like in-memory key-value store built using Node.js and TCP sockets.

Features

  • PING: Replies with PONG
  • ECHO: Replies with the same message
  • SET key value: Stores the key-value pair
  • SET key value PX milliseconds: Stores the key-value pair with expiry
  • GET key: Retrieves the value for the key (if not expired)

๐Ÿ›  Setup

Make sure you have Bun installed.

bun install
bun run dev

This starts the TCP server on port 6379.

๐Ÿงช Test with nc (Netcat)

You can use netcat to send raw RESP (Redis Serialization Protocol) commands.

๐Ÿ” PING

echo -e '*1\r\n$4\r\nPING\r\n' | nc 127.0.0.1 6379

Response:

+PONG

๐Ÿ—ฃ๏ธ ECHO

echo -e '*2\r\n$4\r\nECHO\r\n$5\r\nHello\r\n' | nc 127.0.0.1 6379

Response:

$5
Hello

๐Ÿ—„๏ธ SET

echo -e '*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n' | nc 127.0.0.1 6379

Response:

+OK

๐Ÿ—„๏ธ SET with expiry

echo -e '*5\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n$2\r\nPX\r\n$4\r\n1000\r\n' | nc 127.0.0.1 6379

Response:

+OK

๐Ÿ—„๏ธ GET

echo -e '*2\r\n$3\r\nGET\r\n$3\r\nkey\r\n' | nc 127.0.0.1 6379

Response (if key exists):

$5
value

Response (if key does not exist):

$-1

License

MIT