implementation of redis-like server
https://github.com/ronitrajfr/ronis.git
This is a simple Redis-like in-memory key-value store built using Node.js and TCP sockets.
PING: Replies with PONGECHO: Replies with the same messageSET key value: Stores the key-value pairSET key value PX milliseconds: Stores the key-value pair with expiryGET key: Retrieves the value for the key (if not expired)Make sure you have Bun installed.
bun install
bun run dev
This starts the TCP server on port 6379.
You can use netcat to send raw RESP (Redis Serialization Protocol) commands.
echo -e '*1\r\n$4\r\nPING\r\n' | nc 127.0.0.1 6379
Response:
+PONG
echo -e '*2\r\n$4\r\nECHO\r\n$5\r\nHello\r\n' | nc 127.0.0.1 6379
Response:
$5
Hello
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
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
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