{"id":50787929,"url":"https://github.com/robertolima-dev/memorust","last_synced_at":"2026-06-12T09:04:35.210Z","repository":{"id":362365465,"uuid":"1253734106","full_name":"robertolima-dev/memorust","owner":"robertolima-dev","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-03T21:14:23.000Z","size":117,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-03T23:07:41.637Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertolima-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-29T19:01:37.000Z","updated_at":"2026-06-03T21:39:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/robertolima-dev/memorust","commit_stats":null,"previous_names":["robertolima-dev/memorust"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/robertolima-dev/memorust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertolima-dev%2Fmemorust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertolima-dev%2Fmemorust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertolima-dev%2Fmemorust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertolima-dev%2Fmemorust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertolima-dev","download_url":"https://codeload.github.com/robertolima-dev/memorust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertolima-dev%2Fmemorust/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34236582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-12T09:04:33.719Z","updated_at":"2026-06-12T09:04:35.195Z","avatar_url":"https://github.com/robertolima-dev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Memorust\n\nA lightweight in-memory database written in Rust.\n\nMemorust was created as a learning project to explore systems programming, networking, concurrency, storage engines, and database internals using Rust.\n\nThe project is heavily inspired by Redis and aims to evolve incrementally while keeping the codebase simple and educational.\n\n---\n\n## What is it?\n\nMemorust is an educational Redis clone: a single-binary, in-memory key-value\ndatabase server written in Rust (edition 2024), with Tokio as its only\ndependency. It speaks the RESP protocol, so it is compatible with `redis-cli`\nand existing Redis clients, and supports a subset of Redis commands (`PING`,\n`SET`, `GET`, `DEL`, `EXISTS`, `SETEX`, `EXPIRE`, `TTL`, `INFO`, `FLUSHALL`,\n`AOFREWRITE`) with TTL and Append Only File (AOF) persistence.\n\n## Why does it exist?\n\nMemorust started as a study project to learn, hands-on, how an in-memory\ndatabase works under the hood: async TCP networking, protocol design,\nconcurrency, storage engines, persistence, and performance engineering. The\nfocus is on keeping the code **simple and readable**, serving as learning\nmaterial rather than aiming for full feature parity with Redis.\n\n## How to run it?\n\nYou need a recent stable Rust toolchain (the crate uses **edition 2024**, which\nrequires **Rust 1.85 or newer**). Install it via [rustup](https://rustup.rs/).\n\n```bash\ngit clone https://github.com/robertolima-dev/memorust.git\ncd memorust\ncargo run        # builds and starts the server on 127.0.0.1:6379\n```\n\nIn another terminal, interact with it using `redis-cli` or raw TCP:\n\n```bash\nredis-cli -p 6379\n# then: PING / SET name Roberto / GET name / INFO\n```\n\nTo run the tests:\n\n```bash\ncargo test\n```\n\n## How to contribute?\n\nContributions are very welcome! See the contribution guide in\n[CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow, the required\nchecks, and how to open a pull request. By participating in this project, you\nagree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md).\n\n---\n\n## Features\n\nCurrent implementation:\n\n- TCP Server (Tokio)\n- RESP Protocol support\n- Redis CLI compatibility\n- In-memory key-value storage\n- TTL support\n- Background expiration cleaner\n- Append Only File (AOF) with a buffered writer\n- Periodic `fsync` (≈1s, `appendfsync everysec` style)\n- AOF replay on startup\n- AOF rewrite (compaction)\n- INFO command\n- FLUSHALL command\n- Concurrent client support\n- Concurrent reads under a shared lock (GET/EXISTS/TTL/PING)\n\n---\n\n## Supported Commands\n\n### Connection\n\n```text\nPING\n```\n\nResponse:\n\n```text\nPONG\n```\n\n---\n\n### Key/Value\n\n```text\nSET key value\nGET key\nDEL key\nEXISTS key\n```\n\nExample:\n\n```text\nSET name Roberto\nGET name\nDEL name\n```\n\n---\n\n### Expiration\n\n```text\nSETEX key seconds value\nEXPIRE key seconds\nTTL key\n```\n\nExample:\n\n```text\nSETEX session 60 abc123\nTTL session\n```\n\n---\n\n### Administration\n\n```text\nINFO\nFLUSHALL\nAOFREWRITE\n```\n\nExample:\n\n```text\nINFO\nFLUSHALL\nAOFREWRITE\n```\n\n---\n\n## Architecture\n\nCurrent architecture:\n\n```text\nClient\n  ↓\nTCP Server (Tokio)\n  ↓\nRESP Parser\n  ↓\nCommand Parser\n  ↓\nExecutor\n  ↓\nStore\n  ↓\nAOF\n```\n\n---\n\n## Persistence\n\nMemorust currently uses an Append Only File (AOF).\n\nEvery mutating command is persisted:\n\n```text\nSET\nDEL\nSETEX\nEXPIRE\n```\n\nExample:\n\n```text\nSET name Roberto\nSET city SãoPaulo\nDEL city\n```\n\nThe AOF is replayed automatically during startup.\n\n### Durability model\n\nMutating commands are appended to a buffered writer instead of opening and\nflushing the file on every write. A background task flushes the buffer and\n`fsync`s it to disk roughly once per second (similar to Redis'\n`appendfsync everysec`).\n\nThis keeps the `fsync` off the per-command hot path — and the `fsync` itself\nruns outside the writer lock, so it does not stall in-flight writes. The\ntrade-off is that up to ~1 second of recent writes can be lost on a crash.\n\n---\n\n## Running\n\n### Start server\n\n```bash\ncargo run\n```\n\nDefault address:\n\n```text\n127.0.0.1:6379\n```\n\n---\n\n## Using Redis CLI\n\n```bash\nredis-cli -p 6379\n```\n\nExamples:\n\n```text\nPING\n\nSET name Roberto\n\nGET name\n\nINFO\n```\n\n---\n\n## Running Tests\n\n```bash\ncargo test\n```\n\n---\n\n## Benchmark\n\nExample benchmark:\n\n```bash\n# without pipelining\nredis-benchmark -p 6379 -t set,get -n 100000\n\n# with pipelining (reveals server throughput rather than round-trip latency)\nredis-benchmark -p 6379 -t set,get -n 300000 -P 16\n```\n\nCurrent results (release build, Mac M-series development machine):\n\n| Operation | No pipeline (`-P 1`) | Pipelined (`-P 16`) |\n|-----------|----------------------|---------------------|\n| SET       | ~155k ops/sec        | ~264k ops/sec       |\n| GET       | ~158k ops/sec        | ~1.27M ops/sec      |\n\nWithout pipelining the benchmark is dominated by network round-trips, so it\nmostly measures latency. Under pipelining the server's own ceiling shows: GET\nscales far past SET because reads run concurrently under a shared lock, while\nwrites still serialize on the exclusive lock.\n\n\u003e Earlier versions reported ~75k SET / ~150k GET. The SET gain comes from the\n\u003e buffered AOF writer; the GET gain comes from serving reads under a shared lock.\n\nResults may vary depending on hardware and implementation version.\n\n---\n\n## Roadmap\n\n### Completed\n\n- [x] TCP Server\n- [x] RESP Protocol\n- [x] Redis CLI Compatibility\n- [x] TTL\n- [x] Background Cleaner\n- [x] AOF\n- [x] AOF Replay\n- [x] AOF Rewrite\n- [x] INFO\n- [x] FLUSHALL\n\n### Next Steps\n\n- [x] Buffered AOF Writer (`appendfsync everysec`)\n- [ ] Async AOF Writer\n- [ ] Value Types\n  - [ ] Integer\n  - [ ] JSON\n  - [ ] List\n- [ ] Config.toml\n- [ ] Memory Eviction Policies\n- [ ] Binary Snapshot (.db)\n- [ ] Replication\n- [ ] Cluster Mode\n\n---\n\n## Learning Goals\n\nThis project explores:\n\n- Rust\n- Tokio\n- TCP Networking\n- Protocol Design\n- Concurrency\n- Storage Engines\n- Database Internals\n- Persistence\n- Performance Engineering\n\n---\n\n## License\n\nLicensed under either of\n\n- MIT license ([LICENSE-MIT](LICENSE-MIT))\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))\n\nat your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this project by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertolima-dev%2Fmemorust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertolima-dev%2Fmemorust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertolima-dev%2Fmemorust/lists"}