A Redis-like in-memory key-value store built from scratch in Rust.
Built as part of a Rust learning journey — understanding how Redis
works internally by implementing it.
Redis is an in-memory key-value store used for caching, session
storage, rate limiting, and job queues. It's fast because everything
lives in RAM instead of disk.
This project implements a subset of Redis commands in Rust using
a HashMap as the core data structure.
mini_redis/
├── src/
│ ├── main.rs → entry point + testing
│ └── store.rs → core Redis store implementation
└── Cargo.toml
String → SET name "Arjun"
Integer → SET counter 0 / INCR counter
List → LPUSH / RPUSH / LRANGE
| Command |
Description |
Example |
| SET |
Store a string value |
SET name Arjun |
| GET |
Retrieve a value |
GET name |
| DEL |
Delete a key |
DEL name |
| EXISTS |
Check if key exists |
EXISTS name |
| KEYS |
List all keys |
KEYS |
| FLUSH |
Clear everything |
FLUSH |
| Command |
Description |
Example |
| APPEND |
Append to string |
APPEND name " Mehta" |
| STRLEN |
Length of string |
STRLEN name |
| Command |
Description |
Example |
| INCR |
Increment by 1 |
INCR counter |
| Command |
Description |
Example |
| LPUSH |
Push to front |
LPUSH fruits apple |
| RPUSH |
Push to back |
RPUSH fruits banana |
| LRANGE |
Get range |
LRANGE fruits 0 2 |
HashMap<String, RedisValue> — core data store
- Enum with data —
RedisValue for multiple types
- Private fields + public methods — encapsulation
Option<T> — safe key lookup
Result<T,E> — error handling for type mismatches
entry().or_insert() — default value pattern
* dereference — modify values through references
- Module system —
store.rs + main.rs