1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101# 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](https://bun.sh) installed.
```bash
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
```bash
echo -e '*1\r\n$4\r\nPING\r\n' | nc 127.0.0.1 6379
```
Response:
```bash
+PONG
```
### ๐ฃ๏ธ ECHO
```bash
echo -e '*2\r\n$4\r\nECHO\r\n$5\r\nHello\r\n' | nc 127.0.0.1 6379
```
Response:
```bash
$5
Hello
```
### ๐๏ธ SET
```bash
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:
```bash
+OK
```
### ๐๏ธ SET with expiry
```bash
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:
```bash
+OK
```
### ๐๏ธ GET
```bash
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):
```bash
$5
value
```
Response (if key does not exist):
```bash
$-1
```
## License
[MIT](LICENSE)