A lightweight Redis clone built in Rust. Supports basic Redis commands with TTL (time-to-live) functionality.
- β‘ Async I/O with Tokio
- π Thread-safe with DashMap
- β° TTL/Expiration support
- π¦ Zero dependencies on actual Redis
- π Simple text protocol (works with netcat)
# Clone the repo
git clone https://github.com/littleKitchen/MiniRedis.git
cd MiniRedis
# Build
cargo build --release
# Run
./target/release/MiniRedisStart the server:
./target/release/MiniRedisConnect with netcat or telnet:
nc localhost 6380Or use redis-cli:
redis-cli -p 6380| Command | Description | Example |
|---|---|---|
PING |
Test connection | PING β PONG |
ECHO msg |
Echo message | ECHO hello β hello |
SET key value |
Set a key | SET name Yuxuan |
SET key value EX secs |
Set with TTL | SET token abc123 EX 60 |
GET key |
Get value | GET name β Yuxuan |
DEL key [key ...] |
Delete key(s) | DEL name |
EXISTS key [key ...] |
Check if exists | EXISTS name β 1 |
INCR key |
Increment | INCR counter β 1 |
DECR key |
Decrement | DECR counter β 0 |
EXPIRE key secs |
Set TTL | EXPIRE token 30 |
TTL key |
Get remaining TTL | TTL token β 25 |
KEYS pattern |
List keys | KEYS * |
DBSIZE |
Count keys | DBSIZE β 5 |
FLUSHDB |
Clear all keys | FLUSHDB |
INFO |
Server info | INFO |
QUIT |
Close connection | QUIT |
$ nc localhost 6380
PING
+PONG
SET greeting Hello World
+OK
GET greeting
+Hello World
SET counter 0
+OK
INCR counter
:1
INCR counter
:2
GET counter
+2
SET temp data EX 10
+OK
TTL temp
:9
KEYS *
*3
+greeting
+counter
+temp
DBSIZE
:3
DEL temp
:1
QUIT
+OK
- Tokio - Async runtime for handling concurrent connections
- DashMap - Lock-free concurrent HashMap for thread-safe storage
- Bytes - Efficient byte buffer handling
Default port: 6380 (to avoid conflict with real Redis on 6379)
MIT
Yuxuan Che