Skip to content

cmtdrt/Crabis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crabis

A minimal Redis-like key/value store written in Rust.

It listens on the default Redis port (6379) and supports a tiny subset of the Redis protocol.

Available commands

  • HEALTH
    Simple health check.
    Example: HEALTHOK

  • SET key value
    Stores a string value under a string key.
    Example: SET mykey helloOK

  • GET key
    Retrieves the value for a given key or returns a null bulk string if it does not exist.
    Example: GET mykeyhello

Example

image

How it works

Crabis uses a TcpListener from tokio to accept incoming TCP connections on port 6379.

Each connection is handled in its own asynchronous task using tokio::spawn, so multiple clients can be served concurrently without blocking the main thread.

For storage, it relies on a DashMap, a concurrent hash map. This means multiple tasks can read and write keys at the same time safely and efficiently, without manually managing locks.

Prerequisites

  • redis-cli installed

Getting started

From the project root, you can build and run the server with:

  • Using Cargo

    • cargo build
    • cargo run
  • Using Makefile

    • make start

Crabis now listens on 127.0.0.1:6379.

In another terminal, you can connect with:

redis-cli -h 127.0.0.1 -p 6379

You can also enable the Append Only File (AOF) mode to persist SET commands to disk:

cargo run -- AOF

In AOF mode, every SET key value is appended to a log file so the in-memory store can be reconstructed on restart.

Q&A

Q: Why “Crabis”? What is this stupid name?
A: The project is inspired by Redis (it contains “Red”), and since it’s written in Rust, which is associated with the color orange, I first thought about calling it “Orangeis", but that sounded a bit odd. Since Rust’s mascot is an orange crab, I came up with “Crabis.”

About

A Redis-like key/value store with an optional Append Only File mode to persist SET commands across restarts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors