MemorustMinimal, readable in-memory store in Rust

A lightweight in-memory database, built to be read.

Memorust is a single-binary, in-memory key-value server written in Rust with Tokio. It speaks the RESP protocol, so it works with redis-cli and existing Redis clients, while keeping the code small and readable.

Up and running in seconds

Clone, build and connect with any Redis client.

git clone https://github.com/robertolima-dev/memorust.git
cd memorust
cargo run        # starts the server on 127.0.0.1:6379

# in another terminal
redis-cli -p 6379
> SET name Roberto
> GET name

What it does

A focused subset of Redis, implemented from scratch with readability as the goal.

RESP protocol

Speaks the Redis Serialization Protocol, so redis-cli and existing Redis clients connect with no changes.

Async TCP server

Built on Tokio with concurrent client support and concurrent reads under a shared lock.

TTL & expiration

SETEX, EXPIRE and TTL with a background cleaner that reclaims expired keys.

AOF persistence

Append Only File with a buffered writer, periodic fsync (~1s) and replay on startup.

AOF rewrite

Compacts the log with AOFREWRITE so the on-disk history stays small.

Single binary, one dependency

Rust edition 2024 with Tokio as the only dependency. Easy to build, read and hack on.

Fast where it counts

redis-benchmark on a release build, Apple M-series development machine.

OperationNo pipeline (-P 1)Pipelined (-P 16)
SET~142k ops/sec~264k ops/sec
GET~163k ops/sec~1.27M ops/sec

Without pipelining the benchmark is dominated by network round-trips. Under pipelining the server ceiling shows: reads scale far past writes because GET runs concurrently under a shared lock.

Supported commands

A growing subset of the Redis command set.

Connection

  • PING

Key / Value

  • SET
  • GET
  • DEL
  • EXISTS

Expiration

  • SETEX
  • EXPIRE
  • TTL

Administration

  • INFO
  • FLUSHALL
  • AOFREWRITE

Roadmap

Where Memorust is heading next.

  • TCP server & RESP protocol
  • redis-cli compatibility
  • TTL & background cleaner
  • AOF, replay & rewrite
  • Buffered AOF writer (appendfsync everysec)
  • ·Async AOF writer
  • ·Value types (Integer, JSON, List)
  • ·Config.toml
  • ·Memory eviction policies
  • ·Binary snapshot (.db)
  • ·Replication
  • ·Cluster mode

Join the project

Memorust is open source and contributions are very welcome, from typo fixes to new commands.

Contribute

Read the development workflow, required checks and how to open a pull request.

Contributing guide

Issues & ideas

Found a bug or want to discuss a feature? Open an issue on GitHub.

Open an issue

Code of Conduct

By participating in this project you agree to abide by our Code of Conduct.

Read the Code of Conduct