Skip to content

0xfandom/Mini-Redis-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Mini Redis

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.

What Is This

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.

Architecture

mini_redis/
├── src/
│   ├── main.rs     → entry point + testing
│   └── store.rs    → core Redis store implementation
└── Cargo.toml

Data Types Supported

String  → SET name "Arjun"
Integer → SET counter 0 / INCR counter
List    → LPUSH / RPUSH / LRANGE

Commands Implemented

Core

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

String

Command Description Example
APPEND Append to string APPEND name " Mehta"
STRLEN Length of string STRLEN name

Integer

Command Description Example
INCR Increment by 1 INCR counter

List

Command Description Example
LPUSH Push to front LPUSH fruits apple
RPUSH Push to back RPUSH fruits banana
LRANGE Get range LRANGE fruits 0 2

How To Run

cargo run

Rust Concepts Used

  • 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

Roadmap

  • REPL loop — type commands interactively
  • Command parser — parse raw string input
  • Error module — custom error types with thiserror
  • More commands — DECR MSET MGET RENAME TYPE
  • Hash type — HSET HGET HGETALL
  • TTL — EXPIRE TTL PERSIST
  • TCP server — real Redis protocol
  • Persistence — save to file on exit

About

A Redis-like in-memory key-value store built from scratch in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors